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

add controller permissions to set blockOwnerDeletion #49133

Merged
merged 2 commits into from
Sep 6, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Jul 18, 2017

fixes #51970

blockOwnerDeletion requires delete permissions on the owner object. This adds that permission for our controllers.

@kubernetes/sig-auth-misc

The OwnerReferencesPermissionEnforcement admission plugin now requires `update` permission on the `finalizers` subresource of the referenced owner in order to set `blockOwnerDeletion` on an owner reference.

@k8s-ci-robot k8s-ci-robot added sig/auth Categorizes an issue or PR as relevant to SIG Auth. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 18, 2017
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed labels Jul 18, 2017
@liggitt
Copy link
Member

liggitt commented Jul 18, 2017

is there a related issue, or is this only with an admission plugin enabled?

@deads2k
Copy link
Contributor Author

deads2k commented Jul 18, 2017

is there a related issue, or is this only with an admission plugin enabled?

Only when its enabled. We need to enable it for e2e tests, but I think I'd do that separately.

@liggitt
Copy link
Member

liggitt commented Jul 18, 2017

blocking deletion of the owning object seems like it should require finalization permissions on the owning object more than deletion permissions

@liggitt
Copy link
Member

liggitt commented Jul 18, 2017

this would be a great use case for a consistent finalizers subresource on objects we could require update permissions on, require GC-related operations to go through, etc.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 26, 2017
@caesarxuchao
Copy link
Member

blocking deletion of the owning object seems like it should require finalization permissions on the owning object more than deletion permissions

sgtm.

@deads2k It looks like we haven't enabled the OwnerReferencesPermissionEnforcement admission plugin.Otherwise the missing permissions would had causing problems already. Shall we enable the plugin by default?

@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 Jul 26, 2017
@k8s-github-robot
Copy link

Adding do-not-merge because the release note process has not been followed.
One of the following labels is required "release-note", "release-note-action-required", "release-note-experimental" or "release-note-none".
Please see: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes.

@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jul 26, 2017
@deads2k deads2k closed this Aug 3, 2017
@deads2k deads2k deleted the gc-02-permissions branch August 3, 2017 20:10
@deads2k deads2k restored the gc-02-permissions branch August 3, 2017 20:11
@deads2k deads2k reopened this Aug 3, 2017
@k8s-github-robot
Copy link

Adding do-not-merge/release-note-label-needed because the release note process has not been followed.
One of the following labels is required "release-note", "release-note-action-required", "release-note-experimental" or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

@k8s-github-robot k8s-github-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Aug 30, 2017
@liggitt
Copy link
Member

liggitt commented Sep 5, 2017

I really don't want to give delete permissions to controllers that don't need them, simply so they can pass a synthetic permissions check for this admission plugin. Long-term, I'd like to see a consistent finalizers subresource that finalization operations go through. In the short-term, I'd rather see this do an authorization check of update permissions on a hypothetical finalizers subresource, and give that permission to the controllers.

strawman release note:

The OwnerReferencesPermissionEnforcement admission plugin now requires update permission on the finalizers subresource of the referenced owner in order to set blockOwnerDeletion=true

@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 Sep 5, 2017
@deads2k
Copy link
Contributor Author

deads2k commented Sep 5, 2017

@liggitt updated to use update on <resource>/finalizers

@k8s-github-robot k8s-github-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 5, 2017
// ownerReference can only refer to an object in the same namespace, so attributes.GetNamespace() equals to the owner's namespace
Namespace: attributes.GetNamespace(),
APIGroup: groupVersion.Group,
APIVersion: groupVersion.Version,
Resource: mapping.Resource,
Resource: mapping.Resource + "/finalizers",
Copy link
Member

Choose a reason for hiding this comment

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

subresource field in this struct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subresource field in this struct

fixed.

@deads2k
Copy link
Contributor Author

deads2k commented Sep 5, 2017

/retest

@@ -39,20 +39,29 @@ func (fakeAuthorizer) Authorize(a authorizer.Attributes) (bool, string, error) {
if a.GetVerb() == "delete" {
return false, "", nil
}
if a.GetVerb() == "update" && a.GetSubresource() == "/finalizers" {
Copy link
Member

Choose a reason for hiding this comment

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

"/finalizers" or "finalizers"?

@deads2k
Copy link
Contributor Author

deads2k commented Sep 5, 2017

/retest

@liggitt liggitt added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. kind/bug Categorizes issue or PR as related to a bug. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note-label-needed do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels Sep 5, 2017
@liggitt
Copy link
Member

liggitt commented Sep 5, 2017

this lgtm. @caesarxuchao, any final comments?

relatedly, can you open a doc PR for this admission plugin? kubernetes/website#3588 noted we were missing documentation for it

@caesarxuchao
Copy link
Member

The design and code lgtm. I'm concerned whether it's backward incompatible. I guess it breaks existing users that set blockOwnerDeletion, since no one has permission to update the finalizer subresources.

@liggitt
Copy link
Member

liggitt commented Sep 5, 2017

Only if you enable this admission plugin, and if you did that, all your existing controllers were broken already. Given that there was no documentation around this plug-in, and of the default policy did not work with it, I doubt there are any existing users. I think a release noted change is sufficient

@caesarxuchao
Copy link
Member

Makes sense. LGTM.

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

/retest

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

/approve

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

Tagging per comments

@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 6, 2017
@deads2k deads2k added this to the v1.8 milestone Sep 6, 2017
@derekwaynecarr
Copy link
Member

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: caesarxuchao, deads2k, derekwaynecarr

Associated issue: 51970

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

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 6, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 49133, 51557, 51749, 50842, 52018)

@k8s-github-robot k8s-github-robot merged commit 0ed05f2 into kubernetes:master Sep 6, 2017
@k8s-ci-robot
Copy link
Contributor

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

Test name Commit Details Rerun command
pull-kubernetes-bazel 6077fc8 link /test pull-kubernetes-bazel
pull-kubernetes-unit 2572ea5 link /test pull-kubernetes-unit

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.

@deads2k deads2k deleted the gc-02-permissions branch July 3, 2018 18:01
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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/auth Categorizes an issue or PR as relevant to SIG Auth. 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.

workload controllers can't create resources with GC admission on
6 participants