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

KEP-3895: kubectl delete: Add interactive(-i) flag #3896

Merged
merged 4 commits into from
Jun 15, 2023

Conversation

ardaguclu
Copy link
Member

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 2, 2023
@k8s-ci-robot k8s-ci-robot requested a review from seans3 March 2, 2023 07:52
@k8s-ci-robot k8s-ci-robot added the kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory label Mar 2, 2023
@k8s-ci-robot k8s-ci-robot requested a review from soltysh March 2, 2023 07:52
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 2, 2023
@ardaguclu
Copy link
Member Author

/cc @KnVerey @eddiezane

@ardaguclu
Copy link
Member Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 22, 2023
@ardaguclu
Copy link
Member Author

@soltysh @atiratree could you PTAL?. Thanks.

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Minor nits
/lgtm
/approve

In order to overcome this limitation, this feature will use separate builder to show resources as preview. Current builder
will continue being used as deletion traverse, other builder will be used for preview. Builders must match in terms of
configurations to prevent such discrepancies and required tests will be added to assure that configurations are same or not.
Moreover, deletion will only be performed to the resources whose `uidMap` match the ones in the preview list.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Moreover, deletion will only be performed to the resources whose `uidMap` match the ones in the preview list.
Moreover, deletion will only be performed on the resources whose `.metadata.uid` match the ones gathered in the preview list, to ensure we remove only the resources a user explicitly agreed to.

Copy link
Member

Choose a reason for hiding this comment

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

Does this need a stronger guarantee like RV based matching?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for review @enj.
We need to not delete the resources whose are not in the preview list(especially the cases where user types y after a couple of hours and preview list becomes stale most likely). And uid based check allows us to do it and this looks sufficient for our aim(Since kubectl delete does not know resource versions of resources, that might complicate the issue).

-->
Only standard input via terminal will be supported because main motivation of this flag
is to provide a way to users. That would be a risk if there is exceptional inputs whose are available
for users that we can not handle.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd propose stating this something like:

This mechanism will apply only to client-side operation (kubectl delete) and as mentioned in non-goals section is not meant to solve server-side protection, which can be addressed using custom ValidatingAdmissionWebhook, for example.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2023
@soltysh
Copy link
Contributor

soltysh commented Jun 1, 2023

/assign @johnbelamaric
for PRR review

Copy link
Member

@enj enj left a comment

Choose a reason for hiding this comment

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

Initial review as PRR shadow.

In order to overcome this limitation, this feature will use separate builder to show resources as preview. Current builder
will continue being used as deletion traverse, other builder will be used for preview. Builders must match in terms of
configurations to prevent such discrepancies and required tests will be added to assure that configurations are same or not.
Moreover, deletion will only be performed to the resources whose `uidMap` match the ones in the preview list.
Copy link
Member

Choose a reason for hiding this comment

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

Does this need a stronger guarantee like RV based matching?

-->
- In terms of backwards compatibility, this flag's default will always be false.
- If user cancels deletion, exit code will be 0.
- This flag will not be used with `--raw` flag.
Copy link
Member

Choose a reason for hiding this comment

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

How does this change behave in regards to label based deletion, especially if the set of objects matched by the label changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

This problem is also true for default delete behavior(although agree that this is much more visible with this interactivity flag). We'll delete the resources whose are listed as preview and user confirms. If set of objects belonging to the some label is changed, user should execute kubectl delete again.

Copy link
Member

Choose a reason for hiding this comment

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

Include the intended behavior in the KEP.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Does it make sense?. Thanks.

You can take a look at one potential example of such test in:
https://github.com/kubernetes/kubernetes/pull/97058/files#diff-7826f7adbc1996a05ab52e3f5f02429e94b68ce6bce0dc534d1be636154fded3R246-R282
-->
No, users can only use this feature via enabling environment variable.
Copy link
Member

Choose a reason for hiding this comment

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

You need a test (likely an e2e) that shows that you cannot use the feature when the env var is not set.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good point and I'll add a test case for this. Do you want me to update also the KEP by mentioning this?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2023
@johnbelamaric
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, johnbelamaric, soltysh

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 15, 2023
@wojtek-t
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 Jun 15, 2023
@k8s-ci-robot k8s-ci-robot merged commit dc5d562 into kubernetes:master Jun 15, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone Jun 15, 2023
@ardaguclu ardaguclu deleted the kep-3895 branch June 15, 2023 06:16
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/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants