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

Unable to destroy resources in workspace after workspace removal warning #24019

Closed
pselle opened this issue Feb 3, 2020 · 5 comments
Closed
Labels
backend/tencent Issues related to Tencent Cloud COS backend bug cli v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@pselle
Copy link
Contributor

pselle commented Feb 3, 2020

Terraform Version

0.12.17

Built from #22540

Terraform Configuration Files

terraform {
  backend "cos" {
    region = "na-ashburn"
    bucket = "bucket-for-terraform-state-xxxxxx"
    prefix = "terraform/state"
  }
}

resource "null_resource" "name" {
  for_each = toset(local.x)
}

locals {
  x = ["a","b","c"]
}

Debug Output

https://gist.github.com/pselle/6f8dc4f1ae686398f92b2b6a9a7aade9

Crash Output

Expected Behavior

Should be able to destroy objects in workspace

Actual Behavior

State lock is lingering

Steps to Reproduce

  1. Create a new workspace (ex. space3) populated with objects
  2. terraform workspace select default go to a different workspace
  3. terraform workspaces delete space3 try to delete the workspace, you'll get an error that there are objects remaining, and that it could create lingering objects.
$ terraform workspace delete space3
Acquiring state lock. This may take a few moments...
Workspace "space3" is not empty.

Deleting "space3" can result in dangling resources: resources that
exist but are no longer manageable by Terraform. Please destroy
these resources first.  If you want to delete this workspace
anyway and risk dangling resources, use the '-force' flag.
  1. terraform workspace select space3
  2. terraform destroy Unable to destroy objects, as a state lock is present. This is present through multiple runs/is consistent.

Additional Context

The workflow above is should be able to re-create the error consistently. In addition to being unable to destroy objects in space3, any interaction in the workspace space3 is now blocked by the lingering state lock (cannot apply either)

References

@pselle pselle added the backend/tencent Issues related to Tencent Cloud COS backend label Feb 3, 2020
@pselle
Copy link
Contributor Author

pselle commented Feb 3, 2020

Additionally, after running destroy lock=false, in order to run the destroy anyway, and then deleting the workspace terraform workspace delete space3, I cannot create a new workspace with the same name:

$ terraform workspace new space3
Failed to lock cos state: failed to create tag: tencentcloud-terraform-lock -> 2846f8499a5d2a0809dcf783cceea4d6: [TencentCloudSDKError] Code=ResourceInUse.TagDuplicate, Message=[SWOOLE_WTAG] tagKey-tagValue have exists., RequestId=f0c4602b-066c-47df-8678-e14b09aa5f0b
Lock Info:
  ID:        9dda333eb4a807d9f1b1efc0126c42e1
  Path:      terraform/state/space3/terraform.tfstate.tflock
  Operation: workspace_delete
  Who:       pamselle@Pam-MBP.local
  Version:   0.12.17
  Created:   2020-02-03 16:45:48.151353 +0000 UTC
  Info:      

$ terraform workspace list
  default
* space2

@likexian
Copy link
Contributor

Hello @pselle
Thanks for your testing and issue, I have debug this issue carefully and finally found that this is not the issue of tencentcloud backend but the bug of terraform core, the locker is not released after workspace removal warning.
I have fired a PR, but I am not sure whether my PR is the best solution, please have a review, thanks.

@hashibot hashibot added bug cli v0.12 Issues (primarily bugs) reported against v0.12 releases labels Feb 13, 2020
@likexian
Copy link
Contributor

This has been resolved, please close it.

@pselle pselle closed this as completed Feb 18, 2020
@pselle
Copy link
Contributor Author

pselle commented Feb 18, 2020

This will be included in the next 0.12 release.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend/tencent Issues related to Tencent Cloud COS backend bug cli v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

3 participants