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

Space: improve destroy command #362

Merged
merged 3 commits into from
Aug 23, 2023
Merged

Conversation

darkmuggle
Copy link
Contributor

Description of your changes

For Spaces destroy command:

  • Remove the upbound-system namespace on destroy
  • Make the user confirm the delete

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

Tested against v0.15.1 with Spaces


******************** DESTRUCTIVE COMMAND ********************
****************** DATA-DESTRUCTION WARNING *****************

 WARNING  Destroying Spaces is a destructive command that will destroy data and oprhan resources.
 WARNING  Before proceeding ensure that Managed Resources in Control Planes have been deleted.
 WARNING  All Spaces components including Control Planes will be destroyed.

To proceed, type: "DESTROY CONFIRMED": DESTROY CONFIRMED

@AlainRoy AlainRoy changed the title Space: improve destory command Space: improve destroy command Aug 18, 2023
cmd/up/space/destroy.go Outdated Show resolved Hide resolved

commonParams

Confirmed bool `name:"yes-really-delete-spaces-and-all-data" type:"bool" help:"Bypass safety checks and destroy Spaces"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I love it!

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I love it, but it probably should be singular -- space instead of spaces.

Copy link

Choose a reason for hiding this comment

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

Users might also accept force :-)

Copy link
Member

Choose a reason for hiding this comment

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

I personally like force since it follows other conventions 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I like force and it does follow other conventions, I wanted to make people think.

Copy link
Contributor

@AlainRoy AlainRoy left a comment

Choose a reason for hiding this comment

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

I left nits, but it looks good to me.

@tnthornton
Copy link
Member

Do we want to pipe in allowing them to orphan their resources?

if err := c.mgr.Uninstall(); err != nil {
return err
}
return c.kClient.CoreV1().Namespaces().Delete(context.Background(), nsUpboundSystem, v1.DeleteOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

This would delete the crossplane and upbound-pull-secret that we ask users to create before deploying. Is that OK? I could at least see it making testing more tedious. Maybe we could introduce a flag to skip deleting the namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check the latest push -- we only delete the namespace if there are no orphans.

@darkmuggle
Copy link
Contributor Author

Do we want to pipe in allowing them to orphan their resources?

Yeah, implemented in the last push. The way I did it was to run not execute any hooks when orphan is set. The other way would be to upgrade and set the deletionPolicy, however that doesn't work with out a token file; it seemed crazy to require a token file to remove something. Since the delete is part of a hook, disabling the hook accomplished the same goal.

If you up space destroy --orphan and then up space init things start working again.

@darkmuggle
Copy link
Contributor Author

@tnthornton @branden if the last drop looks good, go ahead and merge.

@tnthornton tnthornton merged commit 2c3e50c into upbound:main Aug 23, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants