Skip to content

Commit

Permalink
server: Make --v2-deprecation=write-only the default and remove not-y…
Browse files Browse the repository at this point in the history
…et option
  • Loading branch information
serathius committed Jan 19, 2022
1 parent 28b9089 commit fcf0d7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions server/config/v2_deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package config
type V2DeprecationEnum string

const (
// Default in v3.5. Issues a warning if v2store have meaningful content.
// No longer supported in v3.6
V2_DEPR_0_NOT_YET = V2DeprecationEnum("not-yet")
// Default in v3.6. Meaningful v2 state is not allowed.
// The V2 files are maintained for v3.5 rollback.
Expand All @@ -28,7 +28,7 @@ const (
// ability to rollback to etcd v3.5.
V2_DEPR_2_GONE = V2DeprecationEnum("gone")

V2_DEPR_DEFAULT = V2_DEPR_0_NOT_YET
V2_DEPR_DEFAULT = V2_DEPR_1_WRITE_ONLY
)

func (e V2DeprecationEnum) IsAtLeast(v2d V2DeprecationEnum) bool {
Expand Down
1 change: 0 additions & 1 deletion server/etcdmain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func newConfig() *config {
proxyFlagOn,
),
v2deprecation: flags.NewSelectiveStringsValue(
string(cconfig.V2_DEPR_0_NOT_YET),
string(cconfig.V2_DEPR_1_WRITE_ONLY),
string(cconfig.V2_DEPR_1_WRITE_ONLY_DROP),
string(cconfig.V2_DEPR_2_GONE)),
Expand Down
29 changes: 13 additions & 16 deletions tests/e2e/v2store_deprecation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ func createV2store(t testing.TB, lastReleaseBinary string, dataDirPath string) {
}
}

func assertVerifyCanStartV2deprecationNotYet(t testing.TB, dataDirPath string) {
t.Log("verify: possible to start etcd with --v2-deprecation=not-yet mode")

cfg := e2e.ConfigStandalone(e2e.EtcdProcessClusterConfig{DataDirPath: dataDirPath, V2deprecation: "not-yet", KeepDataDir: true})
epc, err := e2e.NewEtcdProcessCluster(t, cfg)
assert.NoError(t, err)

defer func() {
assert.NoError(t, epc.Stop())
}()
}

func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath string) {
t.Log("Verify its infeasible to start etcd with --v2-deprecation=write-only mode")
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--v2-deprecation=write-only", "--data-dir=" + dataDirPath}, nil)
Expand All @@ -65,6 +53,15 @@ func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath str
assert.NoError(t, err)
}

func assertVerifyCannotStartV2deprecationNotYet(t testing.TB, dataDirPath string) {
t.Log("Verify its infeasible to start etcd with --v2-deprecation=not-yet mode")
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--v2-deprecation=not-yet", "--data-dir=" + dataDirPath}, nil)
assert.NoError(t, err)

_, err = proc.Expect(`invalid value "not-yet" for flag -v2-deprecation: invalid value "not-yet"`)
assert.NoError(t, err)
}

func TestV2Deprecation(t *testing.T) {
e2e.BeforeTest(t)
dataDirPath := t.TempDir()
Expand All @@ -78,12 +75,12 @@ func TestV2Deprecation(t *testing.T) {
createV2store(t, lastReleaseBinary, dataDirPath)
})

t.Run("--v2-deprecation=write-only fails", func(t *testing.T) {
assertVerifyCannotStartV2deprecationWriteOnly(t, dataDirPath)
t.Run("--v2-deprecation=not-yet fails", func(t *testing.T) {
assertVerifyCannotStartV2deprecationNotYet(t, dataDirPath)
})

t.Run("--v2-deprecation=not-yet succeeds", func(t *testing.T) {
assertVerifyCanStartV2deprecationNotYet(t, dataDirPath)
t.Run("--v2-deprecation=write-only fails", func(t *testing.T) {
assertVerifyCannotStartV2deprecationWriteOnly(t, dataDirPath)
})

}

0 comments on commit fcf0d7f

Please sign in to comment.