Skip to content

Commit

Permalink
fix for etcd-io#19066 Print warnings when deprecated options are conf…
Browse files Browse the repository at this point in the history
…igured in config file

Signed-off-by: mansoora <[email protected]>
  • Loading branch information
mansoor17syed committed Jan 9, 2025
1 parent 8f3d5f6 commit d3c407c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions server/etcdmain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d3c407c

Please sign in to comment.