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

Feature gate initializers field #51436

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Aug 28, 2017

The metadata.initializers field should be feature gated and disabled by default while in alpha, especially since enforcement of initializer permission that keeps users from submitting objects with their own initializers specified is done via an admission plugin most clusters do not enable yet.

Not gating the field and tests caused tests added in #51429 to fail on clusters that don't enable the admission plugin.

This PR:

  • adds an Initializers feature gate, auto-enables the feature gate if the admission plugin is enabled
  • clears the metadata.initializers field of objects on create/update if the feature gate is not set
  • marks the e2e tests as feature-dependent (will follow up with PR to test-infra to enable the feature and opt in for GCE e2e tests)
Use of the alpha initializers feature now requires enabling the `Initializers` feature gate. This feature gate is auto-enabled if the `Initialzers` admission plugin is enabled.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 28, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 28, 2017
@liggitt liggitt assigned smarterclayton and unassigned wojtek-t Aug 28, 2017
@liggitt liggitt added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 28, 2017
@liggitt liggitt force-pushed the initializer-feature branch from fd1589b to f0dfa7c Compare August 28, 2017 01:34
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 28, 2017
@liggitt liggitt force-pushed the initializer-feature branch from f0dfa7c to 50abe14 Compare August 28, 2017 02:14

if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
if err := utilfeature.DefaultFeatureGate.Set(string(features.Initializers) + "=true"); err != nil {
glog.Errorf("error enabling Initializers feature as part of admission plugin setup: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

utilruntime.HandleError

@smarterclayton
Copy link
Contributor

/approve

Setting feature based on presence of Admission controller is very reasonable - the opposite does not make sense. Although it may be novel to some people, so we should make sure we communicate it.

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 28, 2017
@liggitt liggitt force-pushed the initializer-feature branch from 50abe14 to 658956f Compare August 28, 2017 15:11
@liggitt
Copy link
Member Author

liggitt commented Aug 28, 2017

cc @kubernetes/sig-api-machinery-api-reviews

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Aug 28, 2017
@liggitt liggitt added this to the v1.8 milestone Aug 28, 2017
@@ -99,6 +101,12 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx genericapirequest.Context, ob
}
objectMeta.SetGeneration(oldMeta.GetGeneration())

// Ensure Initializers are not set unless the feature is enabled
if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
oldMeta.SetInitializers(nil)
Copy link
Member

Choose a reason for hiding this comment

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

Why setting the oldMeta?

Copy link
Member Author

@liggitt liggitt Aug 28, 2017

Choose a reason for hiding this comment

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

if the feature is disabled, the server should behave as if it doesn't know about the field at all. ideally that would be done in decoding of the existing object from etcd and the sent object from the request based on field gates, but until then, we mimic that by dropping it from all objects here.

@caesarxuchao
Copy link
Member

auto-enables the feature gate if the admission plugin is enabled

Could you add this to the release note? Then lgtm.

@liggitt
Copy link
Member Author

liggitt commented Aug 28, 2017

/retest

@liggitt
Copy link
Member Author

liggitt commented Aug 28, 2017

Could you add this to the release note? Then lgtm.

Added

@caesarxuchao
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 28, 2017
@caesarxuchao
Copy link
Member

/retest

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: caesarxuchao, liggitt, smarterclayton

Associated issue: 51429

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@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.

1 similar comment
@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.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 51471, 50561, 50435, 51473, 51436)

@k8s-github-robot k8s-github-robot merged commit 12d73c3 into kubernetes:master Aug 29, 2017
@liggitt liggitt deleted the initializer-feature branch August 29, 2017 15:28
yujuhong pushed a commit to yujuhong/kubernetes that referenced this pull request Sep 1, 2017
Automatic merge from submit-queue (batch tested with PRs 51707, 51662, 51723, 50163, 51633)

Make feature gate threadsafe

Fixes kubernetes#51548 caused by kubernetes#51436
}

if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
if err := utilfeature.DefaultFeatureGate.Set(string(features.Initializers) + "=true"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Should adding the admission controller really override the feature flag?

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants