-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "server-feature-gates" flag. #18279
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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" | ||
) | ||
|
||
var ( | ||
DefaultEtcdServerFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ | ||
DistributedTracing: {Default: false, PreRelease: featuregate.Alpha}, | ||
StopGRPCServiceOnDefrag: {Default: false, PreRelease: featuregate.Alpha}, | ||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You just added these two features, but they are still controlled by the legacy flags, are you going to migrate them to feature gate in a followup PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. They will be migrated in the next few followup PRs. |
||
} | ||
) | ||
|
||
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason why you replaced
pflag
withflag
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the other flags in
server/embed/config.go
usesflag
instead ofpflag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is good to know. Thanks for your answer. I would think that using
pflag
is better as it is POSIX-compliant, but I do see that across the project, we're usingflag
for flagsets. We still parse flags using Cobra, which makes them POSIX-compliant.