migrate experimental-compaction-sleep-interval flag to compaction-sleep-interval

Signed-off-by: Ajay Sundar Karuppasamy <ajaysundar@google.com>
This commit is contained in:
Ajay Sundar Karuppasamy
2025-02-06 01:18:41 +00:00
parent 299bca3afa
commit e5b39f85a4
5 changed files with 89 additions and 2 deletions

View File

@ -148,6 +148,7 @@ var (
"experimental-bootstrap-defrag-threshold-megabytes": "bootstrap-defrag-threshold-megabytes",
"experimental-max-learners": "max-learners",
"experimental-memory-mlock": "memory-mlock",
"experimental-compaction-sleep-interval": "compaction-sleep-interval",
"experimental-downgrade-check-time": "downgrade-check-time",
}
)
@ -407,7 +408,11 @@ type Config struct {
ExperimentalCompactionBatchLimit int `json:"experimental-compaction-batch-limit"`
CompactionBatchLimit int `json:"compaction-batch-limit"`
// ExperimentalCompactionSleepInterval is the sleep interval between every etcd compaction loop.
// Deprecated in v3.6 and will be decommissioned in v3.7.
// TODO: Delete in v3.7
ExperimentalCompactionSleepInterval time.Duration `json:"experimental-compaction-sleep-interval"`
// CompactionSleepInterval is the sleep interval between every etcd compaction loop.
CompactionSleepInterval time.Duration `json:"compaction-sleep-interval"`
// ExperimentalWatchProgressNotifyInterval is the time duration of periodic watch progress notifications.
// Deprecated in v3.6 and will be decommissioned in v3.7.
// TODO: Delete in v3.7
@ -847,7 +852,8 @@ func (cfg *Config) AddFlags(fs *flag.FlagSet) {
// TODO: delete in v3.7
fs.IntVar(&cfg.ExperimentalCompactionBatchLimit, "experimental-compaction-batch-limit", cfg.ExperimentalCompactionBatchLimit, "Sets the maximum revisions deleted in each compaction batch. Deprecated in v3.6 and will be decommissioned in v3.7. Use --compaction-batch-limit instead.")
fs.IntVar(&cfg.CompactionBatchLimit, "compaction-batch-limit", cfg.CompactionBatchLimit, "Sets the maximum revisions deleted in each compaction batch.")
fs.DurationVar(&cfg.ExperimentalCompactionSleepInterval, "experimental-compaction-sleep-interval", cfg.ExperimentalCompactionSleepInterval, "Sets the sleep interval between each compaction batch.")
fs.DurationVar(&cfg.ExperimentalCompactionSleepInterval, "experimental-compaction-sleep-interval", cfg.ExperimentalCompactionSleepInterval, "Sets the sleep interval between each compaction batch. Deprecated in v3.6 and will be decommissioned in v3.7. Use --compaction-sleep-interval instead.")
fs.DurationVar(&cfg.CompactionSleepInterval, "compaction-sleep-interval", cfg.CompactionSleepInterval, "Sets the sleep interval between each compaction batch.")
// 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.")

View File

@ -227,7 +227,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
EnableLeaseCheckpoint: cfg.ExperimentalEnableLeaseCheckpoint,
LeaseCheckpointPersist: cfg.ExperimentalEnableLeaseCheckpointPersist,
CompactionBatchLimit: cfg.CompactionBatchLimit,
CompactionSleepInterval: cfg.ExperimentalCompactionSleepInterval,
CompactionSleepInterval: cfg.CompactionSleepInterval,
WatchProgressNotifyInterval: cfg.WatchProgressNotifyInterval,
DowngradeCheckTime: cfg.DowngradeCheckTime,
WarningApplyDuration: cfg.WarningApplyDuration,

View File

@ -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-compaction-sleep-interval": "--experimental-compaction-sleep-interval is deprecated in v3.6 and will be decommissioned in v3.7. Use 'compaction-sleep-interval' 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.",
}
)
@ -210,6 +211,10 @@ func (cfg *config) parse(arguments []string) error {
cfg.ec.MemoryMlock = cfg.ec.ExperimentalMemoryMlock
}
if cfg.ec.FlagsExplicitlySet["experimental-compaction-sleep-interval"] {
cfg.ec.CompactionSleepInterval = cfg.ec.ExperimentalCompactionSleepInterval
}
if cfg.ec.FlagsExplicitlySet["experimental-downgrade-check-time"] {
cfg.ec.DowngradeCheckTime = cfg.ec.ExperimentalDowngradeCheckTime
}

View File

@ -618,6 +618,77 @@ func TestCompactHashCheckTimeFlagMigration(t *testing.T) {
}
}
// TestCompactionSleepIntervalFlagMigration tests the migration from
// --experimental-compaction-sleep-interval to --compaction-sleep-interval
func TestCompactionSleepIntervalFlagMigration(t *testing.T) {
testCases := []struct {
name string
compactionSleepInterval string
experimentalCompactionSleepInterval string
wantErr bool
wantConfig time.Duration
}{
{
name: "default",
wantConfig: time.Duration(0),
},
{
name: "cannot set both experimental flag and non experimental flag",
experimentalCompactionSleepInterval: "30s",
compactionSleepInterval: "15s",
wantErr: true,
},
{
name: "can set experimental flag",
experimentalCompactionSleepInterval: "30s",
wantConfig: 30 * time.Second,
},
{
name: "can set non-experimental flag",
compactionSleepInterval: "1m",
wantConfig: time.Minute,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
cmdLineArgs := []string{}
yc := struct {
ExperimentalCompactionSleepInterval time.Duration `json:"experimental-compaction-sleep-interval,omitempty"`
CompactionSleepInterval time.Duration `json:"compaction-sleep-interval,omitempty"`
}{}
if tc.compactionSleepInterval != "" {
cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--compaction-sleep-interval=%s", tc.compactionSleepInterval))
compactionSleepInterval, err := time.ParseDuration(tc.compactionSleepInterval)
require.NoError(t, err)
yc.CompactionSleepInterval = compactionSleepInterval
}
if tc.experimentalCompactionSleepInterval != "" {
cmdLineArgs = append(cmdLineArgs, fmt.Sprintf("--experimental-compaction-sleep-interval=%s", tc.experimentalCompactionSleepInterval))
experimentalCompactionSleepInterval, err := time.ParseDuration(tc.experimentalCompactionSleepInterval)
require.NoError(t, err)
yc.ExperimentalCompactionSleepInterval = experimentalCompactionSleepInterval
}
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.CompactionSleepInterval)
require.Equal(t, tc.wantConfig, cfgFromFile.ec.CompactionSleepInterval)
})
}
}
// TestCorruptCheckTimeFlagMigration tests the migration from
// --experimental-corrupt-check-time to --corrupt-check-time
// TODO: delete in v3.7
@ -1202,6 +1273,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"`
ExperimentalCompactionSleepInterval time.Duration `json:"experimental-compaction-sleep-interval,omitempty"`
ExperimentalDowngradeCheckTime time.Duration `json:"experimental-downgrade-check-time,omitempty"`
}
@ -1227,6 +1299,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
ExperimentalWarningApplyDuration: 3 * time.Minute,
ExperimentalBootstrapDefragThresholdMegabytes: 100,
ExperimentalMaxLearners: 1,
ExperimentalCompactionSleepInterval: 30 * time.Second,
ExperimentalDowngradeCheckTime: 1 * time.Minute,
},
expectedFlags: map[string]struct{}{
@ -1238,6 +1311,7 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
"experimental-warning-apply-duration": {},
"experimental-bootstrap-defrag-threshold-megabytes": {},
"experimental-max-learners": {},
"experimental-compaction-sleep-interval": {},
"experimental-downgrade-check-time": {},
},
},

View File

@ -318,6 +318,8 @@ Experimental feature:
--experimental-snapshot-catch-up-entries '5000'
Number of entries for a slow follower to catch up after compacting the raft storage entries.
--experimental-compaction-sleep-interval
Sets the sleep interval between each compaction batch. Deprecated in v3.6 and will be decommissioned in v3.7. Use 'compaction-sleep-interval' instead.
--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.