forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetcd_features.go
97 lines (89 loc) · 4.17 KB
/
etcd_features.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2024 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package features
import (
"fmt"
"go.uber.org/zap"
"go.etcd.io/etcd/pkg/v3/featuregate"
)
const (
// Every feature gate should add method here following this template:
//
// // owner: @username
// // kep: https://kep.k8s.io/NNN (or issue: https://github.com/etcd-io/etcd/issues/NNN, or main PR: https://github.com/etcd-io/etcd/pull/NNN)
// // alpha: v3.X
// MyFeature featuregate.Feature = "MyFeature"
//
// Feature gates should be listed in alphabetical, case-sensitive
// (upper before any lower case character) order. This reduces the risk
// of code conflicts because changes are more likely to be scattered
// across the file.
// DistributedTracing enables experimental distributed tracing using OpenTelemetry Tracing.
// owner: @dashpole
// alpha: v3.5
// issue: https://github.com/etcd-io/etcd/issues/12460
DistributedTracing featuregate.Feature = "DistributedTracing"
// StopGRPCServiceOnDefrag enables etcd gRPC service to stop serving client requests on defragmentation.
// owner: @chaochn47
// alpha: v3.6
// 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"
// MemoryMlock enables mlock memory to prevent etcd from being swapped to disk.
// owner: @ptabor
// alpha: v3.6
// main PR: https://github.com/etcd-io/etcd/pull/12750
MemoryMlock featuregate.Feature = "MemoryMlock"
)
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},
MemoryMlock: {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,
"experimental-memory-mlock": MemoryMlock,
}
)
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
}