From 9265d67fe6d7b7b9d2f3b60bdb8672cf0ae084ef Mon Sep 17 00:00:00 2001 From: "S. M. Mohiuddin Khan Shiam" Date: Wed, 18 Jun 2025 01:22:53 +0600 Subject: [PATCH] fix(events): respect `--all-namespaces` flag The `flux events` command always applied a namespace filter, even when `--all-namespaces` was set. This produced incomplete results and confused users expecting cluster-wide events. Changes made: * Build `clientListOpts` dynamically. * Omit `client.InNamespace(...)` when `eventArgs.allNamespaces` is true, ensuring no namespace constraint. Impact: `flux events --all-namespaces` now returns events from every namespace, restoring expected functionality without affecting other options. Signed-off-by: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com> --- cmd/flux/events.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/flux/events.go b/cmd/flux/events.go index bcaafae6..dc0bbd66 100644 --- a/cmd/flux/events.go +++ b/cmd/flux/events.go @@ -112,7 +112,12 @@ func eventsCmdRun(cmd *cobra.Command, args []string) error { } var diffRefNs bool - clientListOpts := []client.ListOption{client.InNamespace(*kubeconfigArgs.Namespace)} + // Build the base list options. When --all-namespaces is set we must NOT constrain the + // query to a single namespace, otherwise we silently return a partial result set. + clientListOpts := []client.ListOption{} + if !eventArgs.allNamespaces { + clientListOpts = append(clientListOpts, client.InNamespace(*kubeconfigArgs.Namespace)) + } var refListOpts [][]client.ListOption if eventArgs.forSelector != "" { kind, name := getKindNameFromSelector(eventArgs.forSelector)