Repository: etcd-io/etcd
File: server/features/etcd_features.go (Go)

Code before:
	// main PR: https://github.com/etcd-io/etcd/pull/18279
	StopGRPCServiceOnDefrag featuregate.Feature = "StopGRPCServiceOnDefrag"
	// TxnModeWriteWithSharedBuffer enables the write transaction to use a shared buffer in its readonly check operations.
	// owner: @serathius
	// alpha: v3.6
	// main PR: https://github.com/etcd-io/etcd/pull/12896
	TxnModeWriteWithSharedBuffer featuregate.Feature = "TxnModeWriteWithSharedBuffer"
	// InitialCorruptCheck enable to check data corruption before serving any client/peer traffic.
	// owner: @serathius
	// alpha: v3.6
	// main PR: https://github.com/etcd-io/etcd/pull/10524
	InitialCorruptCheck featuregate.Feature = "InitialCorruptCheck"
	// CompactHashCheck enables leader to periodically check followers compaction hashes.
	// owner: @serathius
	// alpha: v3.6
	// main PR: https://github.com/etcd-io/etcd/pull/14120
	CompactHashCheck featuregate.Feature = "CompactHashCheck"
)

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},
		CompactHashCheck:             {Default: false, PreRelease: featuregate.Alpha},
		TxnModeWriteWithSharedBuffer: {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,
		"experimental-compact-hash-check-enabled":        CompactHashCheck,
		"experimental-txn-mode-write-with-shared-buffer": TxnModeWriteWithSharedBuffer,
	}
)

func NewDefaultServerFeatureGate(name string, lg *zap.Logger) featuregate.FeatureGate {
	fg := featuregate.New(fmt.Sprintf("%sServerFeatureGate", name), lg)
	if err := fg.Add(DefaultEtcdServerFeatureGates); err != nil {
		panic(err)
	}
	return fg
}


Review comment (suggestion):
Flag was enabled to true, we should mark it as enabled by default in feature flag too. We also expect flags enabled by default are Beta.

Code after:
	// main PR: https://github.com/etcd-io/etcd/pull/18279
	StopGRPCServiceOnDefrag featuregate.Feature = "StopGRPCServiceOnDefrag"
	// TxnModeWriteWithSharedBuffer enables the write transaction to use a shared buffer in its readonly check operations.
	// owner: @wilsonwang371
	// beta: v3.5
	// main PR: https://github.com/etcd-io/etcd/pull/12896
	TxnModeWriteWithSharedBuffer featuregate.Feature = "TxnModeWriteWithSharedBuffer"
	// InitialCorruptCheck enable to check data corruption before serving any client/peer traffic.
	// owner: @serathius
	// alpha: v3.6
	// main PR: https://github.com/etcd-io/etcd/pull/10524
	InitialCorruptCheck featuregate.Feature = "InitialCorruptCheck"
	// CompactHashCheck enables leader to periodically check followers compaction hashes.
	// owner: @serathius
	// alpha: v3.6
	// main PR: https://github.com/etcd-io/etcd/pull/14120
	CompactHashCheck featuregate.Feature = "CompactHashCheck"
)

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},
		CompactHashCheck:             {Default: false, PreRelease: featuregate.Alpha},
		TxnModeWriteWithSharedBuffer: {Default: true, PreRelease: featuregate.Beta},
	}
	// 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,
		"experimental-compact-hash-check-enabled":        CompactHashCheck,
		"experimental-txn-mode-write-with-shared-buffer": TxnModeWriteWithSharedBuffer,
	}
)

func NewDefaultServerFeatureGate(name string, lg *zap.Logger) featuregate.FeatureGate {
	fg := featuregate.New(fmt.Sprintf("%sServerFeatureGate", name), lg)
	if err := fg.Add(DefaultEtcdServerFeatureGates); err != nil {
		panic(err)
	}
	return fg
}