From c64486def35e2d0cb0e475355b7dfd6f8a9cd6d2 Mon Sep 17 00:00:00 2001 From: Michi Mutsuzaki Date: Tue, 17 Oct 2023 21:55:52 +0000 Subject: [PATCH] sysdump: Check if enable-envoy-config is set Collect CiliumClusterwideEnvoyConfigs and CiliumEnvoyConfigs custom resources if and only if enable-envoy-config is set to "true". Signed-off-by: Michi Mutsuzaki --- sysdump/sysdump.go | 64 +++++++++++++++++++++----------------- utils/features/features.go | 6 ++++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/sysdump/sysdump.go b/sysdump/sysdump.go index ef9f49df7b..9fb57bdcf9 100644 --- a/sysdump/sysdump.go +++ b/sysdump/sysdump.go @@ -678,34 +678,6 @@ func (c *Collector) Run() error { return nil }, }, - { - Description: "Collecting CiliumClusterwideEnvoyConfigs", - Quick: true, - Task: func(ctx context.Context) error { - v, err := c.Client.ListCiliumClusterwideEnvoyConfigs(ctx, metav1.ListOptions{}) - if err != nil { - return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err) - } - if err := c.WriteYAML(ciliumClusterwideEnvoyConfigsFileName, v); err != nil { - return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err) - } - return nil - }, - }, - { - Description: "Collecting CiliumEnvoyConfigs", - Quick: true, - Task: func(ctx context.Context) error { - v, err := c.Client.ListCiliumEnvoyConfigs(ctx, corev1.NamespaceAll, metav1.ListOptions{}) - if err != nil { - return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err) - } - if err := c.WriteYAML(ciliumEnvoyConfigsFileName, v); err != nil { - return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err) - } - return nil - }, - }, { Description: "Collecting Cilium BGP Peering Policies", Quick: true, @@ -1399,6 +1371,9 @@ func (c *Collector) Run() error { if c.FeatureSet[features.GatewayAPI].Enabled { tasks = append(tasks, c.getGatewayAPITasks()...) } + if c.FeatureSet[features.EnableEnvoyConfig].Enabled { + tasks = append(tasks, c.getEnvoyConfigTasks()...) + } // Adjust the worker count to make enough headroom for tasks that submit sub-tasks. // This is necessary because 'Submit' is blocking. @@ -1718,6 +1693,39 @@ func (c *Collector) getGatewayAPITasks() []Task { } } +func (c *Collector) getEnvoyConfigTasks() []Task { + return []Task{ + { + Description: "Collecting CiliumClusterwideEnvoyConfigs", + Quick: true, + Task: func(ctx context.Context) error { + v, err := c.Client.ListCiliumClusterwideEnvoyConfigs(ctx, metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err) + } + if err := c.WriteYAML(ciliumClusterwideEnvoyConfigsFileName, v); err != nil { + return fmt.Errorf("failed to collect CiliumClusterwideEnvoyConfigs: %w", err) + } + return nil + }, + }, + { + Description: "Collecting CiliumEnvoyConfigs", + Quick: true, + Task: func(ctx context.Context) error { + v, err := c.Client.ListCiliumEnvoyConfigs(ctx, corev1.NamespaceAll, metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err) + } + if err := c.WriteYAML(ciliumEnvoyConfigsFileName, v); err != nil { + return fmt.Errorf("failed to collect CiliumEnvoyConfigs: %w", err) + } + return nil + }, + }, + } +} + func (c *Collector) log(msg string, args ...interface{}) { fmt.Fprintf(c.logWriter, msg+"\n", args...) } diff --git a/utils/features/features.go b/utils/features/features.go index 27e50051d7..55ccbc76c0 100644 --- a/utils/features/features.go +++ b/utils/features/features.go @@ -59,6 +59,8 @@ const ( EgressGateway Feature = "enable-ipv4-egress-gateway" GatewayAPI Feature = "enable-gateway-api" + + EnableEnvoyConfig Feature = "enable-envoy-config" ) // Feature is the name of a Cilium Feature (e.g. l7-proxy, cni chaining mode etc) @@ -255,6 +257,10 @@ func (fs Set) ExtractFromConfigMap(cm *v1.ConfigMap) { fs[GatewayAPI] = Status{ Enabled: cm.Data[string(GatewayAPI)] == "true", } + + fs[EnableEnvoyConfig] = Status{ + Enabled: cm.Data[string(EnableEnvoyConfig)] == "true", + } } func (fs Set) ExtractFromNodes(nodesWithoutCilium map[string]struct{}) {