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

Move to a single prompt during bundle destroy #1583

Merged
merged 23 commits into from
Jul 24, 2024

Conversation

shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Jul 9, 2024

Changes

Right now we ask users for two confirmations when destroying a bundle. One to destroy the resources and one to delete the files. This PR consolidates the two prompts into one.

Tests

Manually

Destroying a bundle with no resources:

➜  bundle-playground git:(master) ✗ cli bundle destroy
All files and directories at the following location will be deleted: /Users/shreyas.goenka@databricks.com/.bundle/bundle-playground/default

Would you like to proceed? [y/n]: y
No resources to destroy
Updating deployment state...
Deleting files...
Destroy complete!

Destroying a bundle with no remote state:

➜  bundle-playground git:(master) ✗ cli bundle destroy
No active deployment found to destroy!

When a user cancells a deployment:

➜  bundle-playground git:(master) ✗ cli bundle destroy
The following resources will be deleted:
  delete job job_1
  delete job job_2
  delete pipeline foo

All files and directories at the following location will be deleted: /Users/shreyas.goenka@databricks.com/.bundle/bundle-playground/default

Would you like to proceed? [y/n]: n
Destroy cancelled!

When a user destroys resources:

➜  bundle-playground git:(master) ✗ cli bundle destroy
The following resources will be deleted:
  delete job job_1
  delete job job_2
  delete pipeline foo

All files and directories at the following location will be deleted: /Users/shreyas.goenka@databricks.com/.bundle/bundle-playground/default

Would you like to proceed? [y/n]: y
Updating deployment state...
Deleting files...
Destroy complete!

@shreyas-goenka shreyas-goenka changed the title Consolidate destroy prompt Move to a single prompt during bundle destroy Jul 9, 2024
bundle/deploy/files/delete.go Outdated Show resolved Hide resolved
bundle/deploy/terraform/destroy.go Outdated Show resolved Hide resolved
libs/terraform/plan.go Show resolved Hide resolved
libs/terraform/plan.go Show resolved Hide resolved
// Core destructive mutators for destroy. These require informed user consent.
destroyCore := bundle.Seq(
terraform.Destroy(),
terraform.StatePush(),
Copy link
Contributor

Choose a reason for hiding this comment

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

(not blocking because it's the same as it was) Why do we push an empty state prior to deleting it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems related to keeping the state consistent before deleting files, to be robust against errors, before we delete root_path.

We used to release the lock before calling files.Delete(). I think it's okay to remove this, will send a followup PR.

ref:
https://github.com/databricks/cli/pull/300/files#diff-26a7ca1d9267b02564c3de57565eea8310ba2099c4df658fb902af54a36662cd

#300 (comment)

@shreyas-goenka shreyas-goenka requested a review from pietern July 17, 2024 14:20
bundle/deploy/terraform/destroy.go Show resolved Hide resolved
bundle/phases/destroy.go Outdated Show resolved Hide resolved
@pietern
Copy link
Contributor

pietern commented Jul 23, 2024

Thanks, LGTM. @andrewnester Could you review as well?

@shreyas-goenka shreyas-goenka added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit e6241e1 Jul 24, 2024
5 checks passed
@shreyas-goenka shreyas-goenka deleted the consolidate-destroy-prompt branch July 24, 2024 13:13
andrewnester added a commit that referenced this pull request Jul 25, 2024
Bundles:
 * Add UUID function to bundle template functions  ([#1612](#1612)).
 * Upgrade TF provider to 1.49.0 ([#1617](#1617)).
 * Upgrade TF provider to 1.49.1 ([#1626](#1626)).
 * Support multiple locations for diagnostics ([#1610](#1610)).
 * Split artifact cleanup into prepare step before build ([#1618](#1618)).
 * Move to a single prompt during bundle destroy ([#1583](#1583)).

Internal:
 * Add tests for the Workspace API readahead cache ([#1605](#1605)).
 * Update Python dependencies before install when upgrading a labs project ([#1624](#1624)).
@andrewnester andrewnester mentioned this pull request Jul 25, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 26, 2024
Bundles:
* Add UUID function to bundle template functions
([#1612](#1612)).
* Upgrade TF provider to 1.49.0
([#1617](#1617)).
* Upgrade TF provider to 1.49.1
([#1626](#1626)).
* Support multiple locations for diagnostics
([#1610](#1610)).
* Split artifact cleanup into prepare step before build
([#1618](#1618)).
* Move to a single prompt during bundle destroy
([#1583](#1583)).

Internal:
* Add tests for the Workspace API readahead cache
([#1605](#1605)).
* Update Python dependencies before install when upgrading a labs
project ([#1624](#1624)).
github-merge-queue bot pushed a commit that referenced this pull request Aug 12, 2024
## Changes
Following up
#1583 (comment).

We can skip pushing because right after `root_path` is deleted, making
this a no-op effectively.
 
## Tests
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.

3 participants