mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server: Make --v2-deprecation=write-only the default and remove not-yet option
This commit is contained in:
parent
986a2b51f4
commit
a1f3c2c7cc
@ -17,7 +17,7 @@ package config
|
|||||||
type V2DeprecationEnum string
|
type V2DeprecationEnum string
|
||||||
|
|
||||||
const (
|
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")
|
V2_DEPR_0_NOT_YET = V2DeprecationEnum("not-yet")
|
||||||
// Default in v3.6. Meaningful v2 state is not allowed.
|
// Default in v3.6. Meaningful v2 state is not allowed.
|
||||||
// The V2 files are maintained for v3.5 rollback.
|
// The V2 files are maintained for v3.5 rollback.
|
||||||
@ -28,7 +28,7 @@ const (
|
|||||||
// ability to rollback to etcd v3.5.
|
// ability to rollback to etcd v3.5.
|
||||||
V2_DEPR_2_GONE = V2DeprecationEnum("gone")
|
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 {
|
func (e V2DeprecationEnum) IsAtLeast(v2d V2DeprecationEnum) bool {
|
||||||
|
@ -122,7 +122,6 @@ func newConfig() *config {
|
|||||||
proxyFlagOn,
|
proxyFlagOn,
|
||||||
),
|
),
|
||||||
v2deprecation: flags.NewSelectiveStringsValue(
|
v2deprecation: flags.NewSelectiveStringsValue(
|
||||||
string(cconfig.V2_DEPR_0_NOT_YET),
|
|
||||||
string(cconfig.V2_DEPR_1_WRITE_ONLY),
|
string(cconfig.V2_DEPR_1_WRITE_ONLY),
|
||||||
string(cconfig.V2_DEPR_1_WRITE_ONLY_DROP),
|
string(cconfig.V2_DEPR_1_WRITE_ONLY_DROP),
|
||||||
string(cconfig.V2_DEPR_2_GONE)),
|
string(cconfig.V2_DEPR_2_GONE)),
|
||||||
|
@ -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) {
|
func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath string) {
|
||||||
t.Log("Verify its infeasible to start etcd with --v2-deprecation=write-only mode")
|
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)
|
proc, err := e2e.SpawnCmd([]string{e2e.BinDir + "/etcd", "--v2-deprecation=write-only", "--data-dir=" + dataDirPath}, nil)
|
||||||
@ -65,6 +53,15 @@ func assertVerifyCannotStartV2deprecationWriteOnly(t testing.TB, dataDirPath str
|
|||||||
assert.NoError(t, err)
|
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) {
|
func TestV2Deprecation(t *testing.T) {
|
||||||
e2e.BeforeTest(t)
|
e2e.BeforeTest(t)
|
||||||
dataDirPath := t.TempDir()
|
dataDirPath := t.TempDir()
|
||||||
@ -78,12 +75,12 @@ func TestV2Deprecation(t *testing.T) {
|
|||||||
createV2store(t, lastReleaseBinary, dataDirPath)
|
createV2store(t, lastReleaseBinary, dataDirPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("--v2-deprecation=not-yet fails", func(t *testing.T) {
|
||||||
|
assertVerifyCannotStartV2deprecationNotYet(t, dataDirPath)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("--v2-deprecation=write-only fails", func(t *testing.T) {
|
t.Run("--v2-deprecation=write-only fails", func(t *testing.T) {
|
||||||
assertVerifyCannotStartV2deprecationWriteOnly(t, dataDirPath)
|
assertVerifyCannotStartV2deprecationWriteOnly(t, dataDirPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("--v2-deprecation=not-yet succeeds", func(t *testing.T) {
|
|
||||||
assertVerifyCanStartV2deprecationNotYet(t, dataDirPath)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user