From 2feaead2b159762a9e9a317dcfa60d74ef6dcff5 Mon Sep 17 00:00:00 2001 From: zirain Date: Fri, 23 May 2025 09:38:24 +0800 Subject: [PATCH] chore: use GetEnvoyProxyComponentLevel Signed-off-by: zirain --- api/v1alpha1/envoyproxy_helpers.go | 5 +++++ api/v1alpha1/validation/envoyproxy_validate_test.go | 4 ++-- internal/infrastructure/common/proxy_args.go | 3 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/v1alpha1/envoyproxy_helpers.go b/api/v1alpha1/envoyproxy_helpers.go index ec69147e65..b141f179cd 100644 --- a/api/v1alpha1/envoyproxy_helpers.go +++ b/api/v1alpha1/envoyproxy_helpers.go @@ -143,6 +143,11 @@ func (logging *ProxyLogging) GetEnvoyProxyComponentLevel() string { } } + if len(args) == 0 { + // use "misc:error" as default + args = []string{"misc:error"} + } + sort.Strings(args) return strings.Join(args, ",") diff --git a/api/v1alpha1/validation/envoyproxy_validate_test.go b/api/v1alpha1/validation/envoyproxy_validate_test.go index 9c96792f54..f6ff1c6b23 100644 --- a/api/v1alpha1/validation/envoyproxy_validate_test.go +++ b/api/v1alpha1/validation/envoyproxy_validate_test.go @@ -847,7 +847,7 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) { }{ { logging: egv1a1.ProxyLogging{}, - expected: "", + expected: "misc:error", }, { logging: egv1a1.ProxyLogging{ @@ -855,7 +855,7 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) { egv1a1.LogComponentDefault: egv1a1.LogLevelInfo, }, }, - expected: "", + expected: "misc:error", }, { logging: egv1a1.ProxyLogging{ diff --git a/internal/infrastructure/common/proxy_args.go b/internal/infrastructure/common/proxy_args.go index 78544b6366..98a7e22cda 100644 --- a/internal/infrastructure/common/proxy_args.go +++ b/internal/infrastructure/common/proxy_args.go @@ -72,9 +72,6 @@ func BuildProxyArgs( if componentsLogLevel := logging.GetEnvoyProxyComponentLevel(); componentsLogLevel != "" { args = append(args, fmt.Sprintf("--component-log-level %s", componentsLogLevel)) - } else { - // Default to error level for misc components if not set. - args = append(args, fmt.Sprintf("--component-log-level %s", "misc:error")) } // Default drain timeout.