Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysdump: fix no Cilium output if operator was not detected #2635

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
14 changes: 9 additions & 5 deletions sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
Loading