From 1d4f9974940de416a28ef56dfb4c49113461b7e7 Mon Sep 17 00:00:00 2001 From: mansoora Date: Thu, 9 Jan 2025 22:27:37 +0530 Subject: [PATCH] fix for #19066 Print warnings when deprecated options are configured in config file Signed-off-by: mansoora --- server/etcdmain/config.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go index ca651e1669c..5e12381d77d 100644 --- a/server/etcdmain/config.go +++ b/server/etcdmain/config.go @@ -182,21 +182,23 @@ func (cfg *config) parse(arguments []string) error { return perr } - var warningsForDeprecatedFlags []string - cfg.cf.flagSet.Visit(func(f *flag.Flag) { - if msg, ok := deprecatedFlags[f.Name]; ok { - warningsForDeprecatedFlags = append(warningsForDeprecatedFlags, msg) + // Check for deprecated options from both command line and config file + var warningsForDeprecatedOpts []string + for flagName := range cfg.ec.FlagsExplicitlySet { + if msg, ok := deprecatedFlags[flagName]; ok { + warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, msg) } - }) - if len(warningsForDeprecatedFlags) > 0 { + } + + // Log warnings if any deprecated options were found + if len(warningsForDeprecatedOpts) > 0 { if lg := cfg.ec.GetLogger(); lg != nil { - for _, msg := range warningsForDeprecatedFlags { + for _, msg := range warningsForDeprecatedOpts { lg.Warn(msg) } } } - // now logger is set up return err }