Skip to content

Commit

Permalink
migrate experimental-initial-corrupt-check flag to feature gate.
Browse files Browse the repository at this point in the history
Signed-off-by: Lan Liang <[email protected]>
  • Loading branch information
liangyuanpeng committed Aug 20, 2024
1 parent 62e4433 commit 54a55bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions server/embed/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.DistributedTracing: false,
features.StopGRPCServiceOnDefrag: false,
features.InitialCorruptCheck: false,
},
},
{
Expand All @@ -120,6 +121,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.DistributedTracing: true,
features.StopGRPCServiceOnDefrag: true,
features.InitialCorruptCheck: false,
},
},
{
Expand All @@ -128,6 +130,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.StopGRPCServiceOnDefrag: true,
features.DistributedTracing: false,
features.InitialCorruptCheck: false,
},
},
{
Expand All @@ -136,6 +139,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.StopGRPCServiceOnDefrag: false,
features.DistributedTracing: false,
features.InitialCorruptCheck: false,
},
},
{
Expand All @@ -144,6 +148,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.StopGRPCServiceOnDefrag: true,
features.DistributedTracing: false,
features.InitialCorruptCheck: false,
},
},
{
Expand All @@ -152,6 +157,7 @@ func TestConfigFileFeatureGates(t *testing.T) {
expectedFeatures: map[featuregate.Feature]bool{
features.StopGRPCServiceOnDefrag: false,
features.DistributedTracing: false,
features.InitialCorruptCheck: false,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"go.etcd.io/etcd/server/v3/etcdserver"
"go.etcd.io/etcd/server/v3/etcdserver/api/etcdhttp"
"go.etcd.io/etcd/server/v3/etcdserver/api/rafthttp"
"go.etcd.io/etcd/server/v3/features"
"go.etcd.io/etcd/server/v3/storage"
"go.etcd.io/etcd/server/v3/verify"
)
Expand Down Expand Up @@ -203,7 +204,6 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
TokenTTL: cfg.AuthTokenTTL,
CORS: cfg.CORS,
HostWhitelist: cfg.HostWhitelist,
InitialCorruptCheck: cfg.ExperimentalInitialCorruptCheck,
CorruptCheckTime: cfg.ExperimentalCorruptCheckTime,
CompactHashCheckEnabled: cfg.ExperimentalCompactHashCheckEnabled,
CompactHashCheckTime: cfg.ExperimentalCompactHashCheckTime,
Expand Down Expand Up @@ -259,7 +259,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {

// newly started member ("memberInitialized==false")
// does not need corruption check
if memberInitialized && srvcfg.InitialCorruptCheck {
if memberInitialized && srvcfg.ServerFeatureGate.Enabled(features.InitialCorruptCheck) {
if err = e.Server.CorruptionChecker().InitialCheck(); err != nil {
// set "EtcdServer" to nil, so that it does not block on "EtcdServer.Close()"
// (nothing to close since rafthttp transports have not been started)
Expand Down
2 changes: 1 addition & 1 deletion server/etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Experimental distributed tracing:
Number of samples to collect per million spans for distributed tracing. Disabled by default.
Experimental feature:
--experimental-initial-corrupt-check 'false'
--experimental-initial-corrupt-check 'false',It's deprecated, and will be decommissioned in v3.7. Use '--feature-gates=InitialCorruptCheck=true' instead.
Enable to check data corruption before serving any client/peer traffic.
--experimental-corrupt-check-time '0s'
Duration of time between cluster corruption check passes.
Expand Down
7 changes: 7 additions & 0 deletions server/features/etcd_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,25 @@ const (
// alpha: v3.6
// main PR: https://github.com/etcd-io/etcd/pull/18279
StopGRPCServiceOnDefrag featuregate.Feature = "StopGRPCServiceOnDefrag"
// InitialCorruptCheck enable to check data corruption before serving any client/peer traffic.
// owner: @
// alpha: v3.6
// main PR: https://github.com/etcd-io/etcd/pull/10524
InitialCorruptCheck featuregate.Feature = "InitialCorruptCheck"
)

var (
DefaultEtcdServerFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
DistributedTracing: {Default: false, PreRelease: featuregate.Alpha},
StopGRPCServiceOnDefrag: {Default: false, PreRelease: featuregate.Alpha},
InitialCorruptCheck: {Default: false, PreRelease: featuregate.Alpha},
}
// ExperimentalFlagToFeatureMap is the map from the cmd line flags of experimental features
// to their corresponding feature gates.
// Deprecated: only add existing experimental features here. DO NOT use for new features.
ExperimentalFlagToFeatureMap = map[string]featuregate.Feature{
"experimental-stop-grpc-service-on-defrag": StopGRPCServiceOnDefrag,
"experimental-initial-corrupt-check": InitialCorruptCheck,
}
)

Expand Down

0 comments on commit 54a55bb

Please sign in to comment.