diff --git a/cli/sysdump.go b/cli/sysdump.go index 2069e548de..98efa7aeaa 100644 --- a/cli/sysdump.go +++ b/cli/sysdump.go @@ -34,8 +34,13 @@ func newCmdSysdump(hooks sysdump.Hooks) *cobra.Command { if sysdumpOptions.CiliumNamespace == "" && cmd.Flags().Changed("namespace") { sysdumpOptions.CiliumNamespace = namespace } - if sysdumpOptions.CiliumOperatorNamespace == "" && cmd.Flags().Changed("namespace") { - sysdumpOptions.CiliumOperatorNamespace = namespace + if sysdumpOptions.CiliumOperatorNamespace == "" { + if cmd.Flags().Changed("namespace") { + sysdumpOptions.CiliumOperatorNamespace = namespace + } else { + // Assume the same namespace for operator as for agent if not specified + sysdumpOptions.CiliumOperatorNamespace = sysdumpOptions.CiliumNamespace + } } // Honor --helm-release-name global flag in case it is set and --cilium-helm-release-name is not set if sysdumpOptions.CiliumHelmReleaseName == "" && cmd.Flags().Changed("helm-release-name") { diff --git a/sysdump/sysdump.go b/sysdump/sysdump.go index a4551d2031..48d756708d 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -19,8 +19,6 @@ import ( "sync" "time" - ciliumdef "github.com/cilium/cilium/pkg/defaults" - "github.com/cilium/cilium/pkg/versioncheck" "github.com/cilium/workerpool" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -32,6 +30,9 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/cli-runtime/pkg/genericclioptions" + ciliumdef "github.com/cilium/cilium/pkg/defaults" + "github.com/cilium/cilium/pkg/versioncheck" + "github.com/cilium/cilium-cli/defaults" "github.com/cilium/cilium-cli/k8s" "github.com/cilium/cilium-cli/utils/features" @@ -198,7 +199,7 @@ func NewCollector(k KubernetesClient, o Options, startTime time.Time, cliVersion c.log("🔮 Detected Cilium installation in namespace: %q", ns) c.Options.CiliumNamespace = ns } else { - c.log("ℹ️ Failed to detect Cilium installation") + c.logWarn("Failed to detect Cilium installation") } } else { c.log("ℹ️ Cilium namespace: %s", c.Options.CiliumNamespace) @@ -210,7 +211,7 @@ func NewCollector(k KubernetesClient, o Options, startTime time.Time, cliVersion c.log("🔮 Detected Cilium operator in namespace: %q", ns) c.Options.CiliumOperatorNamespace = ns } else { - c.log("ℹ️ Failed to detect Cilium operator") + c.logWarn("Failed to detect Cilium operator") } } else { c.log("ℹ️ Cilium operator namespace: %s", c.Options.CiliumOperatorNamespace) @@ -1384,7 +1385,10 @@ func (c *Collector) Run() error { }) } - if c.Options.CiliumNamespace != "" && c.Options.CiliumOperatorNamespace != "" { + // TODO(#2645): Ideally we would split ciliumTasks into + // operator, agent, generic tasks, ..., etc + // and only run then when feasible. + if c.Options.CiliumNamespace != "" || c.Options.CiliumOperatorNamespace != "" { tasks = append(tasks, ciliumTasks...) serialTasks = append(serialTasks, Task{