From 33ac224e71a1cc05a8df54b77dcc91901dd51275 Mon Sep 17 00:00:00 2001 From: Marcel Zieba Date: Wed, 26 Jun 2024 12:31:03 +0200 Subject: [PATCH 1/2] sysdump: fix no Cilium output if operator was not detected Fixes regression from #1776 Signed-off-by: Marcel Zieba --- sysdump/sysdump.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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{ From 14b4a7435a42b2ce89f2919bf91fb08b6fd47c1d Mon Sep 17 00:00:00 2001 From: Marcel Zieba Date: Thu, 27 Jun 2024 09:22:13 +0200 Subject: [PATCH 2/2] sysdump: derive operator namespace from agent namespace if specified Co-authored-by: Michi Mutsuzaki Signed-off-by: Marcel Zieba --- cli/sysdump.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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") {