Skip to content
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

featuregate: adds EtcdServer.FeatureEnabled interface. #18062

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

stackbaek
Copy link

@stackbaek stackbaek commented May 23, 2024

The interface can be used throughout the etcd server binary to check if the feature is enabled or not.

Related task: #18047

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Hi @stackbaek. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@stackbaek
Copy link
Author

/assign @siyuanfoundation

pkg/featuregate/featuregate.go Outdated Show resolved Hide resolved
pkg/featuregate/featuregate.go Outdated Show resolved Hide resolved
@stackbaek
Copy link
Author

per conversation with @siyuanfoundation - I imported k8s.io/component-base/featuregate instead of creating a new featuregate within etcd.

@henrybear327
Copy link
Contributor

@stackbaek Don't forget to signoff your commit with git rebase HEAD~ --signoff!

@siyuanfoundation
Copy link
Contributor

LGTM, Thanks @stackbaek!

@tjungblu
Copy link
Contributor

are we going to have issues with cyclic imports with k8s then?

	k8s.io/apimachinery v0.30.1 // indirect
	k8s.io/component-base v0.30.1 // indirect

@siyuanfoundation
Copy link
Contributor

are we going to have issues with cyclic imports with k8s then?

	k8s.io/apimachinery v0.30.1 // indirect
	k8s.io/component-base v0.30.1 // indirect

neither apimachinery nor component-base depend on etcd. I don't see there is any cyclic dependency.

@stackbaek
Copy link
Author

Updated commit to copy component-base FeatureGate into etcd.

@stackbaek stackbaek marked this pull request as ready for review June 8, 2024 16:37
@henrybear327
Copy link
Contributor

/ok-to-test

go.mod Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 81.38298% with 35 lines in your changes missing coverage. Please review.

Project coverage is 68.92%. Comparing base (8a0054f) to head (6fa2ee7).
Report is 26 commits behind head on main.

Current head 6fa2ee7 differs from pull request most recent head 14e15bc

Please upload reports for the commit 14e15bc to get more accurate results.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
Files Coverage Δ
server/config/config.go 79.76% <ø> (ø)
server/storage/mvcc/key_index.go 64.16% <ø> (ø)
server/storage/wal/metrics.go 100.00% <100.00%> (ø)
server/etcdserver/server.go 81.60% <0.00%> (-0.65%) ⬇️
server/storage/mvcc/revision.go 91.48% <80.00%> (-3.39%) ⬇️
etcdutl/snapshot/v3_snapshot.go 57.43% <64.00%> (+8.53%) ⬆️
pkg/featuregate/feature_gate.go 85.33% <85.33%> (ø)

... and 21 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #18062      +/-   ##
==========================================
- Coverage   68.99%   68.92%   -0.07%     
==========================================
  Files         416      417       +1     
  Lines       35127    35303     +176     
==========================================
+ Hits        24235    24333      +98     
- Misses       9503     9552      +49     
- Partials     1389     1418      +29     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a0054f...14e15bc. Read the comment docs.

@siyuanfoundation
Copy link
Contributor

LGTM. Can you fix the verify error? Thank you!

keabsb added 3 commits June 15, 2024 05:34
The interface can be used throughout the etcd server binary to check if
the feature is enabled or not.

Note that this commit also copies necessary FeatureGate interface from
k8s component-base.

Signed-off-by: Baek <[email protected]>
We'll likely use most of the feature_gate package from component-base.
Also this commit moves the pkg from server/internal/pkg to pkg/.

Signed-off-by: Baek <[email protected]>
The removed packages are:

 * k8s.io/apimachinery/pkg/util/naming
 * k8s.io/klog/v2

Do note that removing naming package necessitates adding feature gate
name argument to featuregate.New().

Signed-off-by: Baek <[email protected]>
@stackbaek
Copy link
Author

/retest

Copy link
Contributor

@henrybear327 henrybear327 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing the foundation for the server-level feature gate @stackbaek!

I will implement my 2 TODOs :)

@stackbaek stackbaek closed this Jun 17, 2024
@stackbaek stackbaek reopened this Jun 17, 2024
@stackbaek
Copy link
Author

/retest

2 similar comments
@stackbaek
Copy link
Author

/retest

@stackbaek
Copy link
Author

/retest

@siyuanfoundation
Copy link
Contributor

/cc @ahrtr

@k8s-ci-robot k8s-ci-robot requested a review from ahrtr June 17, 2024 16:59
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good with a couple minor comments.

Thanks.

Comment on lines +83 to +84
// FeatureGate indicates whether a given feature is enabled or not
type FeatureGate interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// FeatureGate indicates whether a given feature is enabled or not
type FeatureGate interface {
// FeaturesGate is an interface for managing all features. It provides functionality
// to query all known features and determine whether a specific feature is enabled.
type FeaturesGate interface {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! While I do see FeaturesGate captures what it actually does (gates all features), the name FeatureGate is taken from k8s component-base and it seems to be used more widely (~177k match in github) than FeaturesGate (~270). If you don't feel strongly for this name, I do want to keep the name as FeatureGate. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name FeatureGate is taken from k8s component-base and it seems to be used more widely (~177k match in github)

Yes, I know it's copied from k8s component-base. I guess the ~177K match is jus because everyone (including this PR) just copied the name.

Feel free to keep it as it's since the naming has already been widely used & accepted.

@@ -207,6 +208,9 @@ type ServerConfig struct {

// ExperimentalLocalAddress is the local IP address to use when communicating with a peer.
ExperimentalLocalAddress string `json:"experimental-local-address"`

// ServerFeatureGate is a server level feature gate
ServerFeatureGate featuregate.FeatureGate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ServerFeatureGate featuregate.FeatureGate
ServerFeaturesGate featuregate.FeaturesGate

@ahrtr ahrtr merged commit a043da5 into etcd-io:main Jun 19, 2024
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

9 participants