From 6722daf2e869f0cbf0a04445a0767dea7ecd267e Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Wed, 4 Dec 2024 13:42:04 +0000 Subject: [PATCH] Deprecate --v2-deprecation and schedule to remove it in 3.8 Signed-off-by: Benjamin Wang --- server/etcdmain/config.go | 11 ++++++--- server/etcdmain/help.go | 8 +++--- tests/e2e/etcd_config_test.go | 46 ++++++++++++++++++++++++++--------- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go index bf1625e7954..a44cc5ab9e9 100644 --- a/server/etcdmain/config.go +++ b/server/etcdmain/config.go @@ -60,6 +60,7 @@ var ( deprecatedFlags = map[string]string{ // TODO: remove in 3.7. "snapshot-count": "--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7.", + "v2-deprecation": "--v2-deprecation is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input.", } ) @@ -74,9 +75,11 @@ type config struct { // configFlags has the set of flags used for command line parsing a Config type configFlags struct { - flagSet *flag.FlagSet - clusterState *flags.SelectiveStringValue - fallback *flags.SelectiveStringValue + flagSet *flag.FlagSet + clusterState *flags.SelectiveStringValue + fallback *flags.SelectiveStringValue + // Deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input. + // TODO: remove in v3.8. v2deprecation *flags.SelectiveStringsValue } @@ -108,7 +111,7 @@ func newConfig() *config { 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.") fs.Var(cfg.cf.fallback, "discovery-fallback", fmt.Sprintf("Valid values include %q", cfg.cf.fallback.Valids())) 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.") - fs.Var(cfg.cf.v2deprecation, "v2-deprecation", fmt.Sprintf("v2store deprecation stage: %q. ", cfg.cf.v2deprecation.Valids())) + 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())) fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.") // ignored diff --git a/server/etcdmain/help.go b/server/etcdmain/help.go index 81c1b131e4e..8871dca78cf 100644 --- a/server/etcdmain/help.go +++ b/server/etcdmain/help.go @@ -169,12 +169,12 @@ Clustering: --auto-compaction-mode 'periodic' 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. --v2-deprecation '` + string(cconfig.V2DeprDefault) + `' - Phase of v2store deprecation. Allows to opt-in for higher compatibility mode. + Phase of v2store deprecation. Deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input. Supported values: 'not-yet' // Issues a warning if v2store have meaningful content (default in v3.5) - 'write-only' // Custom v2 state is not allowed (planned default in v3.6) - 'write-only-drop-data' // Custom v2 state will get DELETED ! - 'gone' // v2store is not maintained any longer. (planned default in v3.7) + 'write-only' // Custom v2 state is not allowed (default in v3.6) + 'write-only-drop-data' // Custom v2 state will get DELETED ! (planned default in v3.7) + 'gone' // v2store is not maintained any longer. (planned to cleanup anything related to v2store in v3.8) Security: --cert-file '' diff --git a/tests/e2e/etcd_config_test.go b/tests/e2e/etcd_config_test.go index 7e4c347314a..8bc59ab7d34 100644 --- a/tests/e2e/etcd_config_test.go +++ b/tests/e2e/etcd_config_test.go @@ -666,17 +666,39 @@ func TestEtcdTLSVersion(t *testing.T) { func TestEtcdDeprecatedFlags(t *testing.T) { e2e.SkipInShortMode(t) - proc, err := e2e.SpawnCmd( - []string{ - e2e.BinPath.Etcd, - "--name", "e1", - "--snapshot-count=100", - }, nil, - ) - require.NoError(t, err) - require.NoError(t, e2e.WaitReadyExpectProc(context.TODO(), proc, []string{"--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7"})) - require.NoError(t, proc.Stop()) + commonArgs := []string{ + e2e.BinPath.Etcd, + "--name", "e1", + } - proc.Wait() // ensure the port has been released - proc.Close() + testCases := []struct { + name string + args []string + expectedMsg string + }{ + { + name: "snapshot-count", + args: append(commonArgs, "--snapshot-count=100"), + expectedMsg: "--snapshot-count is deprecated in 3.6 and will be decommissioned in 3.7", + }, + { + name: "v2-deprecation", + args: append(commonArgs, "--v2-deprecation", "write-only-drop-data"), + expectedMsg: "--v2-deprecation is deprecated and scheduled for removal in v3.8. The default value is enforced, ignoring user input", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + proc, err := e2e.SpawnCmd( + tc.args, nil, + ) + require.NoError(t, err) + require.NoError(t, e2e.WaitReadyExpectProc(context.TODO(), proc, []string{tc.expectedMsg})) + require.NoError(t, proc.Stop()) + + proc.Wait() // ensure the port has been released + proc.Close() + }) + } }