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

remove global variable dependency from admission plugins #84813

Merged
merged 2 commits into from Nov 12, 2019

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Nov 5, 2019

Adds an admission plugin initializer that passes a set of FeatureGates to the admission plugins during initialization that can then be used to set bool values and avoid coupling global variables together.

func (a *admissionPlugin) InspectFeatureGates(features featuregate.FeatureGate){
    a.myFeatureIsOn = features.Enabled("my-feature")
}

/kind cleanup
/priority important-soon
@kubernetes/sig-api-machinery-pr-reviews

@ravisantoshgudimetla this is how to remove the global dep from admission plugins

NONE

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 5, 2019
@k8s-ci-robot k8s-ci-robot added area/apiserver sig/auth Categorizes an issue or PR as relevant to SIG Auth. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 5, 2019
@@ -73,6 +74,7 @@ func createAggregatorConfig(
&genericConfig,
externalInformers,
genericConfig.LoopbackClientConfig,
feature.DefaultMutableFeatureGate,
Copy link
Member

Choose a reason for hiding this comment

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

pass in feature.DefaultFeatureGate, not the mutable one? (comment applies everywhere)

@@ -65,6 +68,7 @@ func NewRecommendedOptions(prefix string, codec runtime.Codec, processInfo *Proc
Audit: NewAuditOptions(),
Features: NewFeatureOptions(),
CoreAPI: NewCoreAPIOptions(),
FeatureGate: featuregate.NewFeatureGate(), // empty default features
Copy link
Member

Choose a reason for hiding this comment

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

Trying to think what the implications of this are... having multiple feature gate instances floating around seems bad. Are we overriding this with our existing util featureGate buckets anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to think what the implications of this are... having multiple feature gate instances floating around seems bad. Are we overriding this with our existing util featureGate buckets anywhere?

kube-apiserver does. I could choose to reference the on in the apiserver package.

Copy link
Member

Choose a reason for hiding this comment

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

fixing the feature gate impl to error if an unregistered feature is interrogated seems like a good path forward. #84865

Copy link
Member

Choose a reason for hiding this comment

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

it is a little strange that the default here will not have the generic apiserver features registered

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a little strange that the default here will not have the generic apiserver features registered

to my knowledge, our recommend options don't include featuregates

Copy link
Member

Choose a reason for hiding this comment

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

APIResponseCompression: {Default: true, PreRelease: featuregate.Beta},
APIListChunking: {Default: true, PreRelease: featuregate.Beta},
DryRun: {Default: true, PreRelease: featuregate.Beta},
RemainingItemCount: {Default: true, PreRelease: featuregate.Beta},
ServerSideApply: {Default: true, PreRelease: featuregate.Beta},
StorageVersionHash: {Default: true, PreRelease: featuregate.Beta},
WinOverlay: {Default: false, PreRelease: featuregate.Alpha},
WinDSR: {Default: false, PreRelease: featuregate.Alpha},
WatchBookmark: {Default: true, PreRelease: featuregate.GA, LockToDefault: true},
RequestManagement: {Default: false, PreRelease: featuregate.Alpha},
RemoveSelfLink: {Default: false, PreRelease: featuregate.Alpha},

those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have them defined, but we don't actually expose a way to wire them to options in the genericapiserver. Or at least I don't remember them in recommendedoptions

Copy link
Member

@liggitt liggitt Nov 8, 2019

Choose a reason for hiding this comment

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

they're not wired to flags, but the API server still checks them in handlers, etc, so if they're not registered, I'm pretty sure the API server wouldn't run

@yue9944882
Copy link
Member

/retest

Copy link
Contributor Author

@deads2k deads2k left a comment

Choose a reason for hiding this comment

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

asdf

@deads2k deads2k force-pushed the admission-feature-gates branch 2 times, most recently from aa596d9 to 08eca7f Compare November 8, 2019 13:21
@deads2k
Copy link
Contributor Author

deads2k commented Nov 8, 2019

Updated to use the featuregate defined in apiserver that is abused by so many others because it sits high in the stack. Left a comment for future developers to ponder their choices.

@liggitt
Copy link
Member

liggitt commented Nov 8, 2019

/approve

one unit test failure, lgtm otherwise

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@liggitt
Copy link
Member

liggitt commented Nov 8, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2019
@liggitt
Copy link
Member

liggitt commented Nov 8, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2019
@liggitt liggitt added this to the v1.17 milestone Nov 10, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2019
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@deads2k deads2k added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 12, 2019
@deads2k
Copy link
Contributor Author

deads2k commented Nov 12, 2019

updated per comment, retagging.

@deads2k
Copy link
Contributor Author

deads2k commented Nov 12, 2019

/retest

@liggitt
Copy link
Member

liggitt commented Nov 12, 2019

diff -Naupr -x _output /home/prow/go/src/k8s.io/kubernetes/plugin/pkg/admission/noderestriction/BUILD /tmp/verify-bazel.qguOOd/go/src/k8s.io/kubernetes/plugin/pkg/admission/noderestriction/BUILD
--- /home/prow/go/src/k8s.io/kubernetes/plugin/pkg/admission/noderestriction/BUILD	2019-11-12 13:14:11.728674466 +0000
+++ /tmp/verify-bazel.qguOOd/go/src/k8s.io/kubernetes/plugin/pkg/admission/noderestriction/BUILD	2019-11-12 13:15:34.733658705 +0000
@@ -53,6 +53,7 @@ go_test(
         "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
         "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
         "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
+        "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
         "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
         "//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
         "//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",

Run ./hack/update-bazel.sh

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2019
@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2019
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 12, 2019

@deads2k: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-node-e2e-containerd 83f6f27 link /test pull-kubernetes-node-e2e-containerd

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot merged commit 94efa98 into kubernetes:master Nov 12, 2019
@liggitt liggitt removed the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants