Skip to content

Commit 7bb5596

Browse files
authored
Merge pull request #19006 from ahrtr/v2_deprecation_20241204
Deprecate `--v2-deprecation` and schedule to remove it in 3.8
2 parents f128d89 + f54c8f5 commit 7bb5596

File tree

6 files changed

+105
-46
lines changed

6 files changed

+105
-46
lines changed

server/config/v2_deprecation.go

+25-22
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,50 @@ package config
1717
type V2DeprecationEnum string
1818

1919
const (
20-
// No longer supported in v3.6
20+
// V2Depr0NotYet means v2store isn't deprecated yet.
21+
// Default in v3.5, and no longer supported in v3.6.
2122
V2Depr0NotYet = V2DeprecationEnum("not-yet")
22-
// No longer supported in v3.6
23-
//
24-
// Deprecated: Please use V2Depr0NotYet.
23+
24+
// Deprecated: to be decommissioned in 3.7. Please use V2Depr0NotYet.
25+
// TODO: remove in 3.7
2526
//revive:disable-next-line:var-naming
2627
V2_DEPR_0_NOT_YET = V2Depr0NotYet
27-
// Default in v3.6. Meaningful v2 state is not allowed.
28-
// The V2 files are maintained for v3.5 rollback.
2928

30-
V2Depr1WriteOnly = V2DeprecationEnum("write-only")
29+
// V2Depr1WriteOnly means only writing v2store is allowed.
3130
// Default in v3.6. Meaningful v2 state is not allowed.
3231
// The V2 files are maintained for v3.5 rollback.
33-
//
34-
// Deprecated: Please use V2Depr1WriteOnly.
32+
V2Depr1WriteOnly = V2DeprecationEnum("write-only")
33+
34+
// Deprecated: to be decommissioned in 3.7. Please use V2Depr1WriteOnly.
35+
// TODO: remove in 3.7
3536
//revive:disable-next-line:var-naming
3637
V2_DEPR_1_WRITE_ONLY = V2Depr1WriteOnly
3738

38-
// V2store is WIPED if found !!!
39+
// V2Depr1WriteOnlyDrop means v2store is WIPED if found !!!
40+
// Will be default in 3.7.
3941
V2Depr1WriteOnlyDrop = V2DeprecationEnum("write-only-drop-data")
40-
// V2store is WIPED if found !!!
41-
//
42-
// Deprecated: Pleae use V2Depr1WriteOnlyDrop.
42+
43+
// Deprecated: to be decommissioned in 3.7. Pleae use V2Depr1WriteOnlyDrop.
44+
// TODO: remove in 3.7
4345
//revive:disable-next-line:var-naming
4446
V2_DEPR_1_WRITE_ONLY_DROP = V2Depr1WriteOnlyDrop
4547

46-
// V2store is neither written nor read. Usage of this configuration is blocking
48+
// V2Depr2Gone means v2store is completely gone. The v2store is
49+
// neither written nor read. Anything related to v2store will be
50+
// cleaned up in v3.8. Usage of this configuration is blocking
4751
// ability to rollback to etcd v3.5.
4852
V2Depr2Gone = V2DeprecationEnum("gone")
49-
// V2store is neither written nor read. Usage of this configuration is blocking
50-
// ability to rollback to etcd v3.5.
51-
//
52-
// Deprecated: Please use V2Depr2Gone
53+
54+
// Deprecated: to be decommissioned in 3.7. Please use V2Depr2Gone.
55+
// TODO: remove in 3.7
5356
//revive:disable-next-line:var-naming
5457
V2_DEPR_2_GONE = V2Depr2Gone
5558

56-
// Default deprecation level.
59+
// V2DeprDefault is the default deprecation level.
5760
V2DeprDefault = V2Depr1WriteOnly
58-
// Default deprecation level.
59-
//
60-
// Deprecated: Please use V2DeprDefault.
61+
62+
// Deprecated: to be decommissioned in 3.7. Please use V2DeprDefault.
63+
// TODO: remove in 3.7
6164
//revive:disable-next-line:var-naming
6265
V2_DEPR_DEFAULT = V2DeprDefault
6366
)

server/embed/config.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ type Config struct {
459459
// ExperimentalStopGRPCServiceOnDefrag enables etcd gRPC service to stop serving client requests on defragmentation.
460460
ExperimentalStopGRPCServiceOnDefrag bool `json:"experimental-stop-grpc-service-on-defrag"`
461461

462-
// V2Deprecation describes phase of API & Storage V2 support
462+
// V2Deprecation describes phase of API & Storage V2 support.
463+
// Deprecated and scheduled for removal in v3.8.
464+
// Do not set this field for embedded use cases, as it has no effect. However, setting it will not cause any harm.
463465
V2Deprecation config.V2DeprecationEnum `json:"v2-deprecation"`
464466

465467
// ServerFeatureGate is a server level feature gate

server/embed/etcd.go

+2
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ func print(lg *zap.Logger, ec Config, sc config.ServerConfig, memberInitialized
376376

377377
zap.String("downgrade-check-interval", sc.DowngradeCheckTime.String()),
378378
zap.Int("max-learners", sc.ExperimentalMaxLearners),
379+
380+
zap.String("v2-deprecation", string(ec.V2Deprecation)),
379381
)
380382
}
381383

server/etcdmain/config.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var (
6060
deprecatedFlags = map[string]string{
6161
// TODO: remove in 3.7.
6262
"snapshot-count": "--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7.",
63+
"v2-deprecation": "--v2-deprecation is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.",
6364
}
6465
)
6566

@@ -74,9 +75,11 @@ type config struct {
7475

7576
// configFlags has the set of flags used for command line parsing a Config
7677
type configFlags struct {
77-
flagSet *flag.FlagSet
78-
clusterState *flags.SelectiveStringValue
79-
fallback *flags.SelectiveStringValue
78+
flagSet *flag.FlagSet
79+
clusterState *flags.SelectiveStringValue
80+
fallback *flags.SelectiveStringValue
81+
// Deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.
82+
// TODO: remove in v3.8.
8083
v2deprecation *flags.SelectiveStringsValue
8184
}
8285

@@ -108,7 +111,7 @@ func newConfig() *config {
108111
fs.StringVar(&cfg.configFile, "config-file", "", "Path to the server configuration file. Note that if a configuration file is provided, other command line flags and environment variables will be ignored.")
109112
fs.Var(cfg.cf.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %q", cfg.cf.fallback.Valids()))
110113
fs.Var(cfg.cf.clusterState, "initial-cluster-state", "Initial cluster state ('new' when bootstrapping a new cluster or 'existing' when adding new members to an existing cluster). After successful initialization (bootstrapping or adding), flag is ignored on restarts.")
111-
fs.Var(cfg.cf.v2deprecation, "v2-deprecation", fmt.Sprintf("v2store deprecation stage: %q. ", cfg.cf.v2deprecation.Valids()))
114+
fs.Var(cfg.cf.v2deprecation, "v2-deprecation", fmt.Sprintf("v2store deprecation stage: %q. Deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.", cfg.cf.v2deprecation.Valids()))
112115

113116
fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.")
114117
// ignored
@@ -161,9 +164,8 @@ func (cfg *config) parse(arguments []string) error {
161164
err = cfg.configFromCmdLine()
162165
}
163166

164-
if cfg.ec.V2Deprecation == "" {
165-
cfg.ec.V2Deprecation = cconfig.V2DeprDefault
166-
}
167+
// `V2Deprecation` (--v2-deprecation) is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.
168+
cfg.ec.V2Deprecation = cconfig.V2DeprDefault
167169

168170
cfg.ec.WarningUnaryRequestDuration, perr = cfg.parseWarningUnaryRequestDuration()
169171
if perr != nil {

server/etcdmain/help.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ Clustering:
169169
--auto-compaction-mode 'periodic'
170170
Interpret 'auto-compaction-retention' one of: periodic|revision. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention.
171171
--v2-deprecation '` + string(cconfig.V2DeprDefault) + `'
172-
Phase of v2store deprecation. Allows to opt-in for higher compatibility mode.
172+
Phase of v2store deprecation. Deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.
173173
Supported values:
174174
'not-yet' // Issues a warning if v2store have meaningful content (default in v3.5)
175-
'write-only' // Custom v2 state is not allowed (planned default in v3.6)
176-
'write-only-drop-data' // Custom v2 state will get DELETED !
177-
'gone' // v2store is not maintained any longer. (planned default in v3.7)
175+
'write-only' // Custom v2 state is not allowed (default in v3.6)
176+
'write-only-drop-data' // Custom v2 state will get DELETED ! (planned default in v3.7)
177+
'gone' // v2store is not maintained any longer. (planned to cleanup anything related to v2store in v3.8)
178178
179179
Security:
180180
--cert-file ''

tests/e2e/etcd_config_test.go

+62-12
Original file line numberDiff line numberDiff line change
@@ -666,17 +666,67 @@ func TestEtcdTLSVersion(t *testing.T) {
666666
func TestEtcdDeprecatedFlags(t *testing.T) {
667667
e2e.SkipInShortMode(t)
668668

669-
proc, err := e2e.SpawnCmd(
670-
[]string{
671-
e2e.BinPath.Etcd,
672-
"--name", "e1",
673-
"--snapshot-count=100",
674-
}, nil,
675-
)
676-
require.NoError(t, err)
677-
require.NoError(t, e2e.WaitReadyExpectProc(context.TODO(), proc, []string{"--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7"}))
678-
require.NoError(t, proc.Stop())
669+
commonArgs := []string{
670+
e2e.BinPath.Etcd,
671+
"--name", "e1",
672+
}
679673

680-
proc.Wait() // ensure the port has been released
681-
proc.Close()
674+
testCases := []struct {
675+
name string
676+
args []string
677+
expectedMsg string
678+
}{
679+
{
680+
name: "snapshot-count",
681+
args: append(commonArgs, "--snapshot-count=100"),
682+
expectedMsg: "--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7",
683+
},
684+
{
685+
name: "v2-deprecation",
686+
args: append(commonArgs, "--v2-deprecation", "write-only-drop-data"),
687+
expectedMsg: "--v2-deprecation is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input",
688+
},
689+
}
690+
691+
for _, tc := range testCases {
692+
t.Run(tc.name, func(t *testing.T) {
693+
proc, err := e2e.SpawnCmd(
694+
tc.args, nil,
695+
)
696+
require.NoError(t, err)
697+
require.NoError(t, e2e.WaitReadyExpectProc(context.TODO(), proc, []string{tc.expectedMsg}))
698+
require.NoError(t, proc.Stop())
699+
700+
proc.Wait() // ensure the port has been released
701+
proc.Close()
702+
})
703+
}
704+
}
705+
706+
// TestV2DeprecationEnforceDefaultValue verifies that etcd enforces the default V2Deprecation level
707+
// and ignores users input.
708+
func TestV2DeprecationEnforceDefaultValue(t *testing.T) {
709+
e2e.SkipInShortMode(t)
710+
711+
commonArgs := []string{
712+
e2e.BinPath.Etcd,
713+
"--name", "e1",
714+
}
715+
716+
validV2DeprecationLevels := []string{"write-only", "write-only-drop-data", "gone"}
717+
expectedDeprecationLevelMsg := `"v2-deprecation":"write-only"`
718+
719+
for _, optionLevel := range validV2DeprecationLevels {
720+
t.Run(optionLevel, func(t *testing.T) {
721+
proc, err := e2e.SpawnCmd(
722+
append(commonArgs, "--v2-deprecation", optionLevel), nil,
723+
)
724+
require.NoError(t, err)
725+
require.NoError(t, e2e.WaitReadyExpectProc(context.TODO(), proc, []string{expectedDeprecationLevelMsg}))
726+
require.NoError(t, proc.Stop())
727+
728+
proc.Wait() // ensure the port has been released
729+
proc.Close()
730+
})
731+
}
682732
}

0 commit comments

Comments
 (0)