Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Some resources should never be deleted (until the workspace is deleted) #3635

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

Closed
bpmct opened this issue Aug 22, 2022 · 3 comments
Closed

Some resources should never be deleted (until the workspace is deleted) #3635

bpmct opened this issue Aug 22, 2022 · 3 comments

Comments

@bpmct
Copy link
Member

bpmct commented Aug 22, 2022

There are cases where a workspace is started or updated and an important resource is deleted and re-created. Sometimes, this is fine, such as a Kubernetes pod, secret, or another ephemeral resource.

However, some resources (e.g. volume) should never be deleted since it results in data loss. For example, @sreya changed his username in Coder and deleted all of his code in his workspace (fix in #3571)

While that specific issue can be patched at the template level (use uid instead of username for labels), and #802 addresses a template safeguard for parameters, there will still be unexpected ways data will be lost in a template that we (or Coder admins in a deployment) haven't thought of.

Terraform's prevent_destroy 🙌🏼

This meta-argument, when set to true, will cause Terraform to reject with an error any plan that would destroy the infrastructure object associated with the resource, as long as the argument remains present in the configuration.

This meta-argument ensures a resource is never accidentally deleted. However, there are a couple of problems:

  1. You may want to destroy a resource when you "delete" the workspace, but you want to prevent_destroy on stops. There is no built-in way to conditionally apply prevent_destroy: "Variables may not be used here" for prevent_destroy hashicorp/terraform#22544
  2. A bit more unclear: What an admin actually want to prevent_destroy on delete, and perhaps manually clean up orphaned disks on a batch process or something? In this case, a delete workspace would always "fail" in Coder.
@mafredri
Copy link
Member

Same/similar issue brought up in #3386, and potential workarounds discussed.

@bpmct
Copy link
Member Author

bpmct commented Aug 23, 2022

Ah, I totally missed that! Closing as duplicate of #3386

@ammario
Copy link
Member

ammario commented Aug 24, 2022

#3386

@ammario ammario closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2022
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

No branches or pull requests

3 participants