kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.75k stars 894 forks source link

Confirmation Prompt for Delete Commands #1602

Closed amrabdelshafi97 closed 1 month ago

amrabdelshafi97 commented 1 month ago

Description: To enhance safety and minimize human error, especially given recent incidents where a single delete command resulted in the deletion of all resources within a namespace, I propose the addition of a confirmation prompt following the execution of a delete command. This prompt should first display the resources that will be affected by running the equivalent get command and then ask the user to confirm whether they truly want to proceed with the deletion.

Implementation Details:

  1. Command Execution:

    • When a delete command is issued, the system should automatically run the equivalent get command to list the resources that match the delete criteria.
  2. Display Resources:

    • Display the list of resources that will be affected by the delete command to the user.
  3. Confirmation Prompt:

    • Prompt the user with a message asking for confirmation to proceed with the deletion.
    • Example message: “You are about to delete the following resources: [list of resources]. Do you want to continue? (yes/no)”

Why This Is Needed:

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
ardaguclu commented 1 month ago

This feature exists https://github.com/kubernetes/kubectl/blob/382ad8ff117ae966d9efd9380295d77d00c6cb7e/pkg/cmd/delete/delete_flags.go#L163-L165 and tracked by https://github.com/kubernetes/enhancements/issues/3895

amrabdelshafi97 commented 1 month ago

Do you think this flag should be true by default instead? Is it something you are planning to do in the future?

ardaguclu commented 1 month ago

Unfortunately it can't be true as it breaks all the scripts currently running successfully. We are planning to introduce a new preferences feature https://github.com/kubernetes/enhancements/issues/3104 and --interactive flag can be set to true as default within this preferences file.

ardaguclu commented 1 month ago

As this has already done, I'm closing this issue; /close

k8s-ci-robot commented 1 month ago

@ardaguclu: Closing this issue.

In response to [this](https://github.com/kubernetes/kubectl/issues/1602#issuecomment-2134873347): >As this has already done, I'm closing this issue; >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.