Skip to content

Commit

Permalink
migrate experimental-downgrade-check-time to downgrade-check-time
Browse files Browse the repository at this point in the history
Signed-off-by: Ajay Sundar Karuppasamy <ajaysundar@google.com>
  • Loading branch information
ajaysundark committed Feb 4, 2025
1 parent e13196b commit fc3d2ad
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 2 deletions.
11 changes: 10 additions & 1 deletion server/embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ var (
"experimental-bootstrap-defrag-threshold-megabytes": "bootstrap-defrag-threshold-megabytes",
"experimental-max-learners": "max-learners",
"experimental-memory-mlock": "memory-mlock",
"experimental-downgrade-check-time": "downgrade-check-time",
}
)

Expand Down Expand Up @@ -487,7 +488,12 @@ type Config struct {
// Setting this is unsafe and will cause data loss.
UnsafeNoFsync bool `json:"unsafe-no-fsync"`

// ExperimentalDowngradeCheckTime is the duration between two downgrade status checks (in seconds).
// Deprecated in v3.6 and scheduled to be removed in v3.7.
// TODO: Delete `ExperimentalDowngradeCheckTime` in v3.7.
ExperimentalDowngradeCheckTime time.Duration `json:"experimental-downgrade-check-time"`
// DowngradeCheckTime is the duration between two downgrade status checks (in seconds).
DowngradeCheckTime time.Duration `json:"downgrade-check-time"`

// MemoryMlock enables mlocking of etcd owned memory pages.
// The setting improves etcd tail latency in environments were:
Expand Down Expand Up @@ -617,6 +623,7 @@ func NewConfig() *Config {
EnableGRPCGateway: true,

ExperimentalDowngradeCheckTime: DefaultDowngradeCheckTime,
DowngradeCheckTime: DefaultDowngradeCheckTime,
MemoryMlock: false,
// TODO: delete in v3.7
ExperimentalMemoryMlock: false,
Expand Down Expand Up @@ -827,7 +834,9 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) {
// TODO: delete in v3.7
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.DowngradeCheckTime, "downgrade-check-time", cfg.DowngradeCheckTime, "Duration of time between two downgrade status checks.")
// TODO: delete in v3.7
fs.DurationVar(&cfg.ExperimentalDowngradeCheckTime, "experimental-downgrade-check-time", cfg.ExperimentalDowngradeCheckTime, "Duration of time between two downgrade status checks. Deprecated in v3.6 and will be decommissioned in v3.7. Use --downgrade-check-time instead.")
// 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.")
Expand Down
2 changes: 1 addition & 1 deletion server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
CompactionBatchLimit: cfg.CompactionBatchLimit,
CompactionSleepInterval: cfg.ExperimentalCompactionSleepInterval,
WatchProgressNotifyInterval: cfg.WatchProgressNotifyInterval,
DowngradeCheckTime: cfg.ExperimentalDowngradeCheckTime,
DowngradeCheckTime: cfg.DowngradeCheckTime,
WarningApplyDuration: cfg.WarningApplyDuration,
WarningUnaryRequestDuration: cfg.WarningUnaryRequestDuration,
MemoryMlock: cfg.MemoryMlock,
Expand Down
5 changes: 5 additions & 0 deletions server/etcdmain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var (
"experimental-bootstrap-defrag-threshold-megabytes": "--experimental-bootstrap-defrag-threshold-megabytes is deprecated in v3.6 and will be decommissioned in v3.7. Use '--bootstrap-defrag-threshold-megabytes' instead.",
"experimental-max-learners": "--experimental-max-learners is deprecated in v3.6 and will be decommissioned in v3.7. Use '--max-learners' instead.",
"experimental-memory-mlock": "--experimental-memory-mlock is deprecated in v3.6 and will be decommissioned in v3.7. Use '--memory-mlock' instead.",
"experimental-downgrade-check-time": "--experimental-downgrade-check-time is deprecated in v3.6 and will be decommissioned in v3.7. Use '--downgrade-check-time' instead.",
}
)

Expand Down Expand Up @@ -209,6 +210,10 @@ func (cfg *config) parse(arguments []string) error {
cfg.ec.MemoryMlock = cfg.ec.ExperimentalMemoryMlock
}

if cfg.ec.FlagsExplicitlySet["experimental-downgrade-check-time"] {
cfg.ec.DowngradeCheckTime = cfg.ec.ExperimentalDowngradeCheckTime
}

// `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

Expand Down
74 changes: 74 additions & 0 deletions server/etcdmain/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,77 @@ func TestParseFeatureGateFlags(t *testing.T) {
}
}

// TestDowngradeCheckTimeFlagMigration tests the migration from
// --experimental-downgrade-check-time to --downgrade-check-time
func TestDowngradeCheckTimeFlagMigration(t *testing.T) {
testCases := []struct {
name string
downgradeCheckTime string
experimentalDowngradeCheckTime string
wantErr bool
wantConfig time.Duration
}{
{
name: "default",
wantConfig: embed.DefaultDowngradeCheckTime,
},
{
name: "cannot set both experimental flag and non experimental flag",
experimentalDowngradeCheckTime: "1m",
downgradeCheckTime: "2m",
wantErr: true,
},
{
name: "can set experimental flag",
experimentalDowngradeCheckTime: "1m",
wantConfig: time.Minute,
},
{
name: "can set non-experimental flag",
downgradeCheckTime: "2m",
wantConfig: 2 * time.Minute,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
cmdLineArgs := []string{}
yc := struct {
ExperimentalDowngradeCheckTime time.Duration `json:"experimental-downgrade-check-time,omitempty"`
DowngradeCheckTime time.Duration `json:"downgrade-check-time,omitempty"`
}{}

if tc.downgradeCheckTime != "" {
cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--downgrade-check-time=%s", tc.downgradeCheckTime))
downgradeCheckTime, err := time.ParseDuration(tc.downgradeCheckTime)
require.NoError(t, err)
yc.DowngradeCheckTime = downgradeCheckTime
}

if tc.experimentalDowngradeCheckTime != "" {
cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--experimental-downgrade-check-time=%s", tc.experimentalDowngradeCheckTime))
experimentalDowngradeCheckTime, err := time.ParseDuration(tc.experimentalDowngradeCheckTime)
require.NoError(t, err)
yc.ExperimentalDowngradeCheckTime = experimentalDowngradeCheckTime
}

cfgFromCmdLine, errFromCmdLine, cfgFromFile, errFromFile := generateCfgsFromFileAndCmdLine(t, yc, cmdLineArgs)

if tc.wantErr {
if errFromCmdLine == nil || errFromFile == nil {
t.Fatal("expect parse error")
}
return
}
if errFromCmdLine != nil || errFromFile != nil {
t.Fatal("error parsing config")
}

require.Equal(t, tc.wantConfig, cfgFromCmdLine.ec.DowngradeCheckTime)
require.Equal(t, tc.wantConfig, cfgFromFile.ec.DowngradeCheckTime)
})
}
}

// TestCompactHashCheckTimeFlagMigration tests the migration from
// --experimental-compact-hash-check-time to --compact-hash-check-time
// TODO: delete in v3.7
Expand Down Expand Up @@ -1131,6 +1202,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
ExperimentalWarningApplyDuration time.Duration `json:"experimental-warning-apply-duration,omitempty"`
ExperimentalBootstrapDefragThresholdMegabytes uint `json:"experimental-bootstrap-defrag-threshold-megabytes,omitempty"`
ExperimentalMaxLearners int `json:"experimental-max-learners,omitempty"`
ExperimentalDowngradeCheckTime time.Duration `json:"experimental-downgrade-check-time,omitempty"`
}

testCases := []struct {
Expand All @@ -1155,6 +1227,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
ExperimentalWarningApplyDuration: 3 * time.Minute,
ExperimentalBootstrapDefragThresholdMegabytes: 100,
ExperimentalMaxLearners: 1,
ExperimentalDowngradeCheckTime: 1 * time.Minute,
},
expectedFlags: map[string]struct{}{
"experimental-compact-hash-check-enabled": {},
Expand All @@ -1165,6 +1238,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
"experimental-warning-apply-duration": {},
"experimental-bootstrap-defrag-threshold-megabytes": {},
"experimental-max-learners": {},
"experimental-downgrade-check-time": {},
},
},
{
Expand Down
4 changes: 4 additions & 0 deletions server/etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ Experimental feature:
--experimental-compaction-sleep-interval
Sets the sleep interval between each compaction batch.
--experimental-downgrade-check-time
Duration of time between two downgrade status checks. Deprecated in v3.6 and will be decommissioned in v3.7. Use "downgrade-check-time" instead.
--downgrade-check-time
Duration of time between two downgrade status checks.
--downgrade-check-time
Duration of time between two downgrade status checks. Deprecated in v3.6 and will be decommissioned in v3.7. Use "downgrade-check-time" instead.
--experimental-enable-lease-checkpoint-persist 'false'
Enable persisting remainingTTL to prevent indefinite auto-renewal of long lived leases. Always enabled in v3.6. Should be used to ensure smooth upgrade from v3.5 clusters with this feature enabled. Requires experimental-enable-lease-checkpoint to be enabled.
--experimental-memory-mlock
Expand Down

0 comments on commit fc3d2ad

Please sign in to comment.