diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go index 5955d8b772b..ca651e1669c 100644 --- a/server/etcdmain/config.go +++ b/server/etcdmain/config.go @@ -182,6 +182,20 @@ 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) + } + }) + if len(warningsForDeprecatedFlags) > 0 { + if lg := cfg.ec.GetLogger(); lg != nil { + for _, msg := range warningsForDeprecatedFlags { + lg.Warn(msg) + } + } + } + // now logger is set up return err } @@ -274,21 +288,6 @@ func (cfg *config) configFromCmdLine() error { return err } - // Check for deprecated command line flags - var warningsForDeprecatedFlags []string - cfg.cf.flagSet.Visit(func(f *flag.Flag) { - if msg, ok := deprecatedFlags[f.Name]; ok { - warningsForDeprecatedFlags = append(warningsForDeprecatedFlags, msg) - } - }) - if len(warningsForDeprecatedFlags) > 0 { - if lg := cfg.ec.GetLogger(); lg != nil { - for _, msg := range warningsForDeprecatedFlags { - lg.Warn(msg) - } - } - } - return cfg.validate() } @@ -299,50 +298,6 @@ func (cfg *config) configFromFile(path string) error { } cfg.ec = *eCfg - // Check for deprecated options in config file - var warningsForDeprecatedOpts []string - - // Check snapshot-count - if cfg.ec.SnapshotCount != 0 { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["snapshot-count"]) - } - - // Check max-snapshots - if cfg.ec.MaxSnapFiles != 0 { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["max-snapshots"]) - } - - // Check v2-deprecation - if cfg.ec.V2Deprecation != "" { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["v2-deprecation"]) - } - - // Check experimental flags - if cfg.ec.ExperimentalCompactHashCheckEnabled { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["experimental-compact-hash-check-enabled"]) - } - if cfg.ec.ExperimentalCompactHashCheckTime != 0 { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["experimental-compact-hash-check-time"]) - } - if cfg.ec.ExperimentalTxnModeWriteWithSharedBuffer { - warningsForDeprecatedOpts = append(warningsForDeprecatedOpts, - deprecatedFlags["experimental-txn-mode-write-with-shared-buffer"]) - } - - // Log warnings if any deprecated options were found - if len(warningsForDeprecatedOpts) > 0 { - if lg := cfg.ec.GetLogger(); lg != nil { - for _, msg := range warningsForDeprecatedOpts { - lg.Warn(msg) - } - } - } - return nil }