diff --git a/server/embed/config.go b/server/embed/config.go index 94306637235..fec01e4b614 100644 --- a/server/embed/config.go +++ b/server/embed/config.go @@ -137,6 +137,7 @@ var ( "experimental-corrupt-check-time": "corrupt-check-time", "experimental-compaction-batch-limit": "compaction-batch-limit", "experimental-watch-progress-notify-interval": "watch-progress-notify-interval", + "experimental-warning-apply-duration": "warning-apply-duration", } ) @@ -403,7 +404,10 @@ type Config struct { WatchProgressNotifyInterval time.Duration `json:"watch-progress-notify-interval"` // ExperimentalWarningApplyDuration is the time duration after which a warning is generated if applying request // takes more time than this value. + // Deprecated in v3.6 and will be decommissioned in v3.7. + // TODO: Delete in v3.7 ExperimentalWarningApplyDuration time.Duration `json:"experimental-warning-apply-duration"` + WarningApplyDuration time.Duration `json:"warning-apply-duration"` // ExperimentalBootstrapDefragThresholdMegabytes is the minimum number of megabytes needed to be freed for etcd server to // consider running defrag during bootstrap. Needs to be set to non-zero value to take effect. ExperimentalBootstrapDefragThresholdMegabytes uint `json:"experimental-bootstrap-defrag-threshold-megabytes"` @@ -551,10 +555,10 @@ func NewConfig() *Config { SnapshotCount: etcdserver.DefaultSnapshotCount, SnapshotCatchUpEntries: etcdserver.DefaultSnapshotCatchUpEntries, - MaxTxnOps: DefaultMaxTxnOps, - MaxRequestBytes: DefaultMaxRequestBytes, - MaxConcurrentStreams: DefaultMaxConcurrentStreams, - ExperimentalWarningApplyDuration: DefaultWarningApplyDuration, + MaxTxnOps: DefaultMaxTxnOps, + MaxRequestBytes: DefaultMaxRequestBytes, + MaxConcurrentStreams: DefaultMaxConcurrentStreams, + WarningApplyDuration: DefaultWarningApplyDuration, GRPCKeepAliveMinTime: DefaultGRPCKeepAliveMinTime, GRPCKeepAliveInterval: DefaultGRPCKeepAliveInterval, @@ -806,7 +810,9 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) { fs.DurationVar(&cfg.ExperimentalWatchProgressNotifyInterval, "experimental-watch-progress-notify-interval", cfg.ExperimentalWatchProgressNotifyInterval, "Duration of periodic watch progress notifications. Deprecated in v3.6 and will be decommissioned in v3.7. Use --watch-progress-notify-interval instead.") fs.DurationVar(&cfg.WatchProgressNotifyInterval, "watch-progress-notify-interval", cfg.WatchProgressNotifyInterval, "Duration of periodic watch progress notifications.") fs.DurationVar(&cfg.ExperimentalDowngradeCheckTime, "experimental-downgrade-check-time", cfg.ExperimentalDowngradeCheckTime, "Duration of time between two downgrade status checks.") - fs.DurationVar(&cfg.ExperimentalWarningApplyDuration, "experimental-warning-apply-duration", cfg.ExperimentalWarningApplyDuration, "Time duration after which a warning is generated if request takes more time.") + // TODO: delete in v3.7 + fs.DurationVar(&cfg.ExperimentalWarningApplyDuration, "experimental-warning-apply-duration", cfg.ExperimentalWarningApplyDuration, "Time duration after which a warning is generated if request takes more time.Deprecated in v3.6 and will be decommissioned in v3.7. Use --warning-watch-progress-duration instead.") + fs.DurationVar(&cfg.WarningApplyDuration, "warning-apply-duration", cfg.WarningApplyDuration, "Time duration after which a warning is generated if watch progress takes more time.") fs.DurationVar(&cfg.WarningUnaryRequestDuration, "warning-unary-request-duration", cfg.WarningUnaryRequestDuration, "Time duration after which a warning is generated if a unary request takes more time.") fs.DurationVar(&cfg.ExperimentalWarningUnaryRequestDuration, "experimental-warning-unary-request-duration", cfg.ExperimentalWarningUnaryRequestDuration, "Time duration after which a warning is generated if a unary request takes more time. It's deprecated, and will be decommissioned in v3.7. Use --warning-unary-request-duration instead.") fs.BoolVar(&cfg.ExperimentalMemoryMlock, "experimental-memory-mlock", cfg.ExperimentalMemoryMlock, "Enable to enforce etcd pages (in particular bbolt) to stay in RAM.") diff --git a/server/embed/etcd.go b/server/embed/etcd.go index c3491588989..a047aa7747f 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -231,7 +231,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { CompactionSleepInterval: cfg.ExperimentalCompactionSleepInterval, WatchProgressNotifyInterval: cfg.WatchProgressNotifyInterval, DowngradeCheckTime: cfg.ExperimentalDowngradeCheckTime, - WarningApplyDuration: cfg.ExperimentalWarningApplyDuration, + WarningApplyDuration: cfg.WarningApplyDuration, WarningUnaryRequestDuration: cfg.WarningUnaryRequestDuration, ExperimentalMemoryMlock: cfg.ExperimentalMemoryMlock, ExperimentalBootstrapDefragThresholdMegabytes: cfg.ExperimentalBootstrapDefragThresholdMegabytes, diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go index 633bf053bd4..560edee6c51 100644 --- a/server/etcdmain/config.go +++ b/server/etcdmain/config.go @@ -68,6 +68,7 @@ var ( "experimental-corrupt-check-time": "--experimental-corrupt-check-time is deprecated in v3.6 and will be decommissioned in v3.7. Use '--corrupt-check-time' instead.", "experimental-compaction-batch-limit": "--experimental-compaction-batch-limit is deprecated in v3.6 and will be decommissioned in v3.7. Use '--compaction-batch-limit' instead.", "experimental-watch-progress-notify-interval": "--experimental-watch-progress-notify-interval is deprecated in v3.6 and will be decommissioned in v3.7. Use '--watch-progress-notify-interval' instead.", + "experimental-warning-apply-duration": "--experimental-warning-apply-duration is deprecated in v3.6 and will be decommissioned in v3.7. Use '--warning-apply-duration' instead.", } ) @@ -189,6 +190,10 @@ func (cfg *config) parse(arguments []string) error { cfg.ec.WatchProgressNotifyInterval = cfg.ec.ExperimentalWatchProgressNotifyInterval } + if cfg.ec.FlagsExplicitlySet["experimental-warning-apply-duration"] { + cfg.ec.WarningApplyDuration = cfg.ec.ExperimentalWarningApplyDuration + } + // `V2Deprecation` (--v2-deprecation) is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input. cfg.ec.V2Deprecation = cconfig.V2DeprDefault diff --git a/server/etcdmain/config_test.go b/server/etcdmain/config_test.go index 0cbaa9c1a97..5a37a301e83 100644 --- a/server/etcdmain/config_test.go +++ b/server/etcdmain/config_test.go @@ -750,6 +750,82 @@ func TestWatchProgressNotifyInterval(t *testing.T) { } } +// TestWarningApplyDuration tests the migration from +// --experimental-warning-apply-duration to --warning-apply-duration +// TODO: delete in v3.7 +func TestWarningApplyDuration(t *testing.T) { + testCases := []struct { + name string + warningApplyDuration string + experimentalWarningApplyDuration string + expectErr bool + expectedWarningApplyDuration time.Duration + }{ + { + name: "cannot set both experimental flag and non experimental flag", + warningApplyDuration: "2m", + experimentalWarningApplyDuration: "3m", + expectErr: true, + }, + { + name: "can set experimental flag", + experimentalWarningApplyDuration: "3m", + expectedWarningApplyDuration: 3 * time.Minute, + }, + { + name: "can set non experimental flag", + warningApplyDuration: "2m", + expectedWarningApplyDuration: 2 * time.Minute, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + cmdLineArgs := []string{} + yc := struct { + ExperimentalWarningApplyDuration time.Duration `json:"experimental-warning-apply-duration,omitempty"` + WarningApplyDuration time.Duration `json:"warning-apply-duration,omitempty"` + }{} + + if tc.warningApplyDuration != "" { + cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--warning-apply-duration=%s", tc.warningApplyDuration)) + warningApplyDuration, err := time.ParseDuration(tc.warningApplyDuration) + if err != nil { + t.Fatal(err) + } + yc.WarningApplyDuration = warningApplyDuration + } + + if tc.experimentalWarningApplyDuration != "" { + cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--experimental-warning-apply-duration=%s", tc.experimentalWarningApplyDuration)) + experimentalWarningApplyDuration, err := time.ParseDuration(tc.experimentalWarningApplyDuration) + if err != nil { + t.Fatal(err) + } + yc.ExperimentalWarningApplyDuration = experimentalWarningApplyDuration + } + + cfgFromCmdLine, errFromCmdLine, cfgFromFile, errFromFile := generateCfgsFromFileAndCmdLine(t, yc, cmdLineArgs) + + if tc.expectErr { + if errFromCmdLine == nil || errFromFile == nil { + t.Fatal("expect parse error") + } + return + } + if errFromCmdLine != nil || errFromFile != nil { + t.Fatal("error parsing config") + } + + if cfgFromCmdLine.ec.WarningApplyDuration != tc.expectedWarningApplyDuration { + t.Errorf("expected WarningApplyDuration=%v, got %v", tc.expectedWarningApplyDuration, cfgFromCmdLine.ec.WarningApplyDuration) + } + if cfgFromFile.ec.WarningApplyDuration != tc.expectedWarningApplyDuration { + t.Errorf("expected WarningApplyDuration=%v, got %v", tc.expectedWarningApplyDuration, cfgFromFile.ec.WarningApplyDuration) + } + }) + } +} + // TODO delete in v3.7 func generateCfgsFromFileAndCmdLine(t *testing.T, yc any, cmdLineArgs []string) (*config, error, *config, error) { b, err := yaml.Marshal(&yc) @@ -862,6 +938,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) { ExperimentalCorruptCheckTime time.Duration `json:"experimental-corrupt-check-time,omitempty"` ExperimentalCompactionBatchLimit int `json:"experimental-compaction-batch-limit,omitempty"` ExperimentalWatchProgressNotifyInterval time.Duration `json:"experimental-watch-progress-notify-interval,omitempty"` + ExperimentalWarningApplyDuration time.Duration `json:"experimental-warning-apply-duration,omitempty"` } testCases := []struct { @@ -883,6 +960,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) { ExperimentalCorruptCheckTime: time.Minute, ExperimentalCompactionBatchLimit: 1, ExperimentalWatchProgressNotifyInterval: 3 * time.Minute, + ExperimentalWarningApplyDuration: 3 * time.Minute, }, expectedFlags: map[string]struct{}{ "experimental-compact-hash-check-enabled": {}, @@ -890,6 +968,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) { "experimental-corrupt-check-time": {}, "experimental-compaction-batch-limit": {}, "experimental-watch-progress-notify-interval": {}, + "experimental-warning-apply-duration": {}, }, }, { diff --git a/server/etcdmain/help.go b/server/etcdmain/help.go index 1cd88e98607..0637789b3d2 100644 --- a/server/etcdmain/help.go +++ b/server/etcdmain/help.go @@ -298,6 +298,8 @@ Experimental feature: --watch-progress-notify-interval '10m' Duration of periodical watch progress notification. --experimental-warning-apply-duration '100ms' + Warning is generated if requests take more than this duration. Deprecated in v3.6 and will be decommissioned in v3.7. Use 'warning-apply-duration' instead. + --warning-apply-duration '100ms' Warning is generated if requests take more than this duration. --experimental-txn-mode-write-with-shared-buffer 'true'. Deprecated in v3.6 and will be decommissioned in v3.7. Use '--feature-gates=TxnModeWriteWithSharedBuffer=true' instead. Enable the write transaction to use a shared buffer in its readonly check operations.