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

Fix missing confirmation for reset #1251

Merged

Conversation

shibumi
Copy link
Contributor

@shibumi shibumi commented Feb 21, 2021

What this PR does / why we need it:

This PR adds a request for confirmation for the reset subcommand.
We have a request for confirmation already in the apply subcommand, hence it should not be much work
adding the same question to reset. I really think reset should have such a question, because it destroys
the whole cluster.

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

None

Special notes for your reviewer:

The functionality works so far, but I am not sure about the implementation. Actually it would be nicer to have access to the
LiveCluster object inside of reset, because the Cluster object doesn't seem to be "Dynamic Worker"-aware.
Furthermore it looks like the hostnames are missing when I test it:

The following nodes will be resetted: 
        + reset control plane node "" (10.88.10.2)
        + reset control plane node "" (10.88.10.3)
        + reset control plane node "" (10.88.10.4)
        + reset static worker nodes "" (10.88.10.11)
        + reset static worker nodes "" (10.88.10.12)
        + reset static worker nodes "" (10.88.10.13)
Do you want to proceed (yes/no): no

INFO[01:49:46 CET] Operation canceled.     

Does this have something to do with missing network access? I tested this without the VPN connection to my cluster (I did not have another cluster to test right now and I did not want to delete one of our company clusters out of a mistake).

Does this PR introduce a user-facing change?:

[BREAKING/ACTION REQUIRED] The kubeone reset command requires an explicit confirmation like the apply command. The command can be automatically approved by using the --auto-approve flag.

@kubermatic-bot kubermatic-bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. dco-signoff: no Denotes that at least one commit in the pull request doesn't have a valid DCO signoff message. labels Feb 21, 2021
@kubermatic-bot
Copy link
Contributor

Hi @shibumi. Thanks for your PR.

I'm waiting for a kubermatic member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@kubermatic-bot kubermatic-bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 21, 2021
@shibumi
Copy link
Contributor Author

shibumi commented Feb 21, 2021

/assign @xrstf

@shibumi shibumi force-pushed the shibumi/ask-confirm-for-reset branch from c09fba5 to 4042b18 Compare February 21, 2021 01:02
@kubermatic-bot kubermatic-bot added dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. and removed dco-signoff: no Denotes that at least one commit in the pull request doesn't have a valid DCO signoff message. labels Feb 21, 2021
@xrstf xrstf removed their assignment Feb 21, 2021
@xrstf xrstf requested review from xmudrii and kron4eg February 21, 2021 02:03
@kron4eg
Copy link
Member

kron4eg commented Feb 21, 2021

This is breaking CLI change. But on the other hand it's precautionary measure. I'm not sure how to proceed.
@xmudrii WDYT?

@shibumi
Copy link
Contributor Author

shibumi commented Feb 21, 2021

@kron4eg it is indeed a breaking CLI change, but I really think we should have such functionality :) My solution may not be the best, but it's definitely something the reset sub command should have. I was really surprised when I used kubeone reset the first time.

@xmudrii
Copy link
Member

xmudrii commented Feb 22, 2021

@shibumi Thank you for the PR! We've discussed it internally, and we agree that there should be a confirmation for the reset command because it's very destructive. However, this is a breaking CLI change and it should be handle as such. We considered the following two approaches:

  1. Create a new command that would replace the reset command, and that would have the confirmation. The new command would deprecate the reset command, which we would remove after one or two releases
    • The problem is that reset very well describes what's done by the command, so it would be hard to come up with a new name
    • It's not that big breaking change that requires a new command
  2. Starting with the upcoming 1.2 release (planned for the upcoming weeks), we would show a warning when users run kubeone reset that starting with the 1.3 release, the command will require confirmation. We would also announce this in the changelog. In this case, we would merge your PR after creating the release branch for the 1.2 release (that's going to happen in the upcoming weeks)

We've decided to go with the second approach (to show a warning) because it seems like the best approach for moving forward.

I'll put this PR on an explicit hold until we don't create a release branch. In meanwhile, I'll leave some comments which you can address.
/hold

If you want, you can create another PR that would add a warning to the kubeone reset command to say that the command will ask for a confirmation starting with the 1.3 release. It can say something along:

This command will require an explicit confirmation starting with the next release

@kubermatic-bot kubermatic-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 22, 2021
@shibumi
Copy link
Contributor Author

shibumi commented Feb 22, 2021

  • It's not that big breaking change that requires a new command
  1. Starting with the upcoming 1.2 release (planned for the upcoming weeks), we would show a warning when users run kubeone reset that starting with the 1.3 release, the command will require confirmation. We would also announce this in the changelog. In this case, we would merge your PR after creating the release branch for the 1.2 release (that's going to happen in the upcoming weeks)

We've decided to go with the second approach (to show a warning) because it seems like the best approach for moving forward.

Full ACK. The second option makes more sense. Would be a shame to deprecate the reset command only for a confirmation flag.

I'll put this PR on an explicit hold until we don't create a release branch. In meanwhile, I'll leave some comments which you can address.

Will have a look on your suggestions after work :) Until tomorrow you should have an updated version.

/hold

If you want, you can create another PR that would add a warning to the kubeone reset command to say that the command will ask for a confirmation starting with the 1.3 release. It can say something along:

This command will require an explicit confirmation starting with the next release

Will have a look on this, too.

@xmudrii
Copy link
Member

xmudrii commented Feb 22, 2021

@shibumi You'll also need to update E2E tests to run the reset command with the --auto-approve flag here:

kubeone/test/e2e/kubeone.go

Lines 185 to 197 in 1683388

// Reset runs 'kubeone reset' command to destroy worker nodes and unprovision the cluster
func (k1 *Kubeone) Reset() error {
err := k1.run("reset",
"-v",
"--tfjson", "tf.json",
"--destroy-workers",
"--manifest", k1.ConfigurationFilePath)
if err != nil {
return fmt.Errorf("destroing workers failed: %w", err)
}
return nil
}

@shibumi shibumi force-pushed the shibumi/ask-confirm-for-reset branch from 4042b18 to 56216ad Compare February 22, 2021 20:52
@kubermatic-bot kubermatic-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 22, 2021
@shibumi shibumi force-pushed the shibumi/ask-confirm-for-reset branch from 56216ad to 131843e Compare February 22, 2021 20:53
@shibumi
Copy link
Contributor Author

shibumi commented Feb 22, 2021

@xmudrii I made sure that the tests are running through now..

Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

Tiny nits.

@shibumi shibumi force-pushed the shibumi/ask-confirm-for-reset branch from 131843e to 470a032 Compare February 22, 2021 21:08
@kubermatic-bot kubermatic-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 13, 2021
@shibumi
Copy link
Contributor Author

shibumi commented May 13, 2021

@xmudrii done

@xmudrii
Copy link
Member

xmudrii commented May 14, 2021

/test all

Signed-off-by: Christian Rebischke <chris@shibumi.dev>
@kubermatic-bot kubermatic-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 14, 2021
@shibumi
Copy link
Contributor Author

shibumi commented May 14, 2021

@xmudrii done. Shall I squash commits or is the commit history fine? My feeling is it's a little bit too atomic.

@xmudrii
Copy link
Member

xmudrii commented May 14, 2021

@shibumi We automatically squash all PRs on merge.

/test all

@shibumi
Copy link
Contributor Author

shibumi commented May 14, 2021

@xmudrii what does this mean?

pkg/cmd/apply.go:29: File is not goimports-ed with -local k8c.io/kubeone (goimports)
"github.com/spf13/pflag"

Signed-off-by: Christian Rebischke <chris@shibumi.dev>
@xmudrii
Copy link
Member

xmudrii commented May 14, 2021

/test all

@kubermatic-bot kubermatic-bot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. 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. labels May 14, 2021
Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

@shibumi Thank you for the contribution!

/lgtm
/approve

@kron4eg PTAL and remove the hold.

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label May 14, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c3c1ab0c33ba562bed1049b514eb18a20aad8b48

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shibumi, xmudrii

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

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2021
@shibumi
Copy link
Contributor Author

shibumi commented May 14, 2021

@xmudrii /retest please :) it was a timeout of your Ci system.

@kron4eg
Copy link
Member

kron4eg commented May 14, 2021

/retest

1 similar comment
@xmudrii
Copy link
Member

xmudrii commented May 14, 2021

/retest

@shibumi
Copy link
Contributor Author

shibumi commented May 14, 2021

The merge label is blocking the merge

@kron4eg
Copy link
Member

kron4eg commented May 14, 2021

/unhold

@kubermatic-bot kubermatic-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 14, 2021
@kubermatic-bot kubermatic-bot merged commit 5a349bf into kubermatic:master May 14, 2021
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.3 milestone May 14, 2021
@shibumi shibumi deleted the shibumi/ask-confirm-for-reset branch May 15, 2021 03:13
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. 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.

5 participants