Skip to content

Fixes delete admission nil object attributes#66535

Closed
yue9944882 wants to merge 1 commit intokubernetes:masterfrom
yue9944882:fixes-delete-admission-nil-object-attributes
Closed

Fixes delete admission nil object attributes#66535
yue9944882 wants to merge 1 commit intokubernetes:masterfrom
yue9944882:fixes-delete-admission-nil-object-attributes

Conversation

@yue9944882
Copy link
Copy Markdown
Member

@yue9944882 yue9944882 commented Jul 24, 2018

What this PR does / why we need it:

Fixes nil old object in admission attributes for storage delete calls.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #66536

Special notes for your reviewer:

This PR doesn't change the current behavior of kube-apiserver.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. 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 Jul 24, 2018
@yue9944882
Copy link
Copy Markdown
Member Author

yue9944882 commented Jul 24, 2018

/sig api-machinery
/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Jul 24, 2018
Copy link
Copy Markdown
Member Author

@yue9944882 yue9944882 Jul 24, 2018

Choose a reason for hiding this comment

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

For reviewers, forcing the name via accessor here is because that DeleteCollections will set an empty name in the attributes.

@yue9944882 yue9944882 force-pushed the fixes-delete-admission-nil-object-attributes branch 5 times, most recently from 5593744 to c386a21 Compare July 24, 2018 06:59
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We call admission for each element in the collection?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi @CaoShuFeng, thanks for reviewing! I am sort of confused here when I found that we are actually not doing loose admission checks in delete collection. Shouldn't we force the check for every item of it?

attrs := admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, "", scope.Resource, scope.Subresource, admission.Delete, userInfo)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The changes here are not quite related to the PR tho.. Or we can put the changes into another PR so that this PR doesn't change any behavior of the server.

Copy link
Copy Markdown
Contributor

@CaoShuFeng CaoShuFeng Jul 24, 2018

Choose a reason for hiding this comment

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

Shouldn't we force the check for every item of it?

If we have remote admission controllers set, this will not be that good.

e.g. I delete a collection of 1000 elements, than the api-server will call the remote admission controller 1000 times in a short time, this will be a flood I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@CaoShuFeng Thanks, these changes reverted.

@yue9944882 yue9944882 force-pushed the fixes-delete-admission-nil-object-attributes branch 3 times, most recently from 53f82d1 to 2128cf0 Compare July 24, 2018 09:18
@yue9944882
Copy link
Copy Markdown
Member Author

/cc @deads2k @liggitt @sttts

@k8s-ci-robot k8s-ci-robot requested review from liggitt and sttts July 24, 2018 09:49
@yue9944882
Copy link
Copy Markdown
Member Author

/test pull-kubernetes-integration

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Jul 24, 2018

See questions raised in
#27193 (comment) guaranteeing the delete admission is called

@liggitt liggitt added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Jul 24, 2018
@yue9944882
Copy link
Copy Markdown
Member Author

(Update guarantees this by requiring the call in order to get the updated data)

Thanks @liggitt . I'm afraid I got a little confused about the line above. In the Update calls we only guarantee the mutating validation call to ensure that the object has to be mutated as expected but other validation funcs like createValidation and updateValidation are not really guaranteed for those storage impl. OTOH, is it really neccesary to force mutating on a delete call? i.e. what is the purpose to mutate an object before deletion?

Do you mean that guaranteeing both mutating and validating admission check for object deletion via some approach like Update's guaranteeing mutating checks?

Does admission get called for the delete operation twice if something is gracefully deleted, then actually deleted (I'd expect it to)

Current state of this PR is right doing admission check twice for graceful deletion IMHO.😃

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this change means that admission is not actually called for namespaces on the first delete request (since this function does a r.store.Storage.GuaranteedUpdate call internally to set the deletion timestamp and namespace finalizer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@liggitt Added the validation check for these manual update-on-delete

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here, admission is not called on first delete

@yue9944882 yue9944882 force-pushed the fixes-delete-admission-nil-object-attributes branch 2 times, most recently from ef059d0 to 4a16762 Compare July 25, 2018 15:48
@caesarxuchao
Copy link
Copy Markdown
Contributor

@yue9944882 do you have time reviving this PR? We need this fix for webhook GA. I can complete this PR if you are busy with the rate limiting project.

@yue9944882
Copy link
Copy Markdown
Member Author

@caesarxuchao heh sure, take it and go 😋

@caesarxuchao
Copy link
Copy Markdown
Contributor

@yue9944882 thanks, do you mind squashing the commits to one? That way I can keep your authorship by cherrypicking just one commit.

backward compatibility: add validation for direct storage delete calls

apply nil validation to existing tests

revert behavior changes in deleteCollection call

fixes validation on wiring graceful deletion

remove nil validation check

continue admission check on not found error
@yue9944882 yue9944882 force-pushed the fixes-delete-admission-nil-object-attributes branch from 1c33139 to ab07482 Compare March 28, 2019 02:59
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yue9944882
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: deads2k

If they are not already assigned, you can assign the PR to them by writing /assign @deads2k in a comment when ready.

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

The pull request process is described here

Details 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

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

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

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-100-performance ab07482 link /test pull-kubernetes-e2e-gce-100-performance
pull-kubernetes-kubemark-e2e-gce-big ab07482 link /test pull-kubernetes-kubemark-e2e-gce-big
pull-kubernetes-bazel-test ab07482 link /test pull-kubernetes-bazel-test
pull-kubernetes-bazel-build ab07482 link /test pull-kubernetes-bazel-build
pull-kubernetes-integration ab07482 link /test pull-kubernetes-integration
pull-kubernetes-godeps ab07482 link /test pull-kubernetes-godeps
pull-kubernetes-verify ab07482 link /test pull-kubernetes-verify
pull-kubernetes-typecheck ab07482 link /test pull-kubernetes-typecheck
pull-kubernetes-node-e2e ab07482 link /test pull-kubernetes-node-e2e
pull-kubernetes-e2e-gce-device-plugin-gpu ab07482 link /test pull-kubernetes-e2e-gce-device-plugin-gpu
pull-kubernetes-e2e-gce ab07482 link /test pull-kubernetes-e2e-gce

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.

Details

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.

@yue9944882
Copy link
Copy Markdown
Member Author

thanks for asking. squashed.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Apr 29, 2019

closing in favor of #76346

/close

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@liggitt: Closed this PR.

Details

In response to this:

closing in favor of #76346

/close

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.

caesarxuchao pushed a commit to caesarxuchao/kubernetes that referenced this pull request May 1, 2019
validate deletion admission object

backward compatibility: add validation for direct storage delete calls

apply nil validation to existing tests

revert behavior changes in deleteCollection call

fixes validation on wiring graceful deletion

remove nil validation check

continue admission check on not found error
caesarxuchao pushed a commit to caesarxuchao/kubernetes that referenced this pull request May 17, 2019
validate deletion admission object

backward compatibility: add validation for direct storage delete calls

apply nil validation to existing tests

revert behavior changes in deleteCollection call

fixes validation on wiring graceful deletion

remove nil validation check

continue admission check on not found error
kkkkun pushed a commit to kkkkun/kubernetes that referenced this pull request Nov 1, 2024
validate deletion admission object

backward compatibility: add validation for direct storage delete calls

apply nil validation to existing tests

revert behavior changes in deleteCollection call

fixes validation on wiring graceful deletion

remove nil validation check

continue admission check on not found error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

Old object of admission attributes is always nil on delete calls

7 participants