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

Set variable id to null if workspace id doesnt exist #227

Merged
merged 1 commit into from
Oct 1, 2020
Merged

Set variable id to null if workspace id doesnt exist #227

merged 1 commit into from
Oct 1, 2020

Conversation

im2nguyen
Copy link
Contributor

Description

Addresses #195
Configuration containing a TFE variable will fail if the workspace is destroyed in the UI. This change destroys the variable resource in state if the workspace it belongs to no longer exists.

BREAKING CHANGE

Delete this section if your change is not introducing a breaking change to the provider or a breaking change from the TFE API

  • New TFE API version created
  • Provider restricted to TFE API version

Testing plan

  1. Describe how to replicate
  2. the conditions
  3. under which your code performs its purpose,
  4. including example Terraform configs where necessary.

External links

Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.

Output from acceptance tests

Please run the full suite of acceptance tests locally and include the output here.

$ make testacc

...

@ghost ghost added the size/XS label Sep 30, 2020
@engd
Copy link

engd commented Sep 30, 2020

Also, the managing workspace gets stuck in the "Error" state since it can't find the manually deleted workspaces anymore. Any workaround suggestions?

@im2nguyen
Copy link
Contributor Author

@engd which version of the TFE provider are you using?

This should be handled in the most recent version of the TFE provider - https://github.com/terraform-providers/terraform-provider-tfe/blob/master/tfe/resource_tfe_workspace.go#L211-L219.

@engd
Copy link

engd commented Sep 30, 2020

@im2nguyen thanks for your answer. I updated to 0.21.0 but it didn't fix it.

@im2nguyen
Copy link
Contributor Author

Can you include the logs attached with the run?

export TF_LOG=DEBUG runs Terraform in debug mode

@engd
Copy link

engd commented Sep 30, 2020

We are using TFE to create an organization and multiple workspaces in it. I am getting the same error for each workspace.

2020/09/30 18:51:10 [ERROR] module.origin.module.dreamcatcher: eval: *terraform.EvalRefresh, err: Error retrieving workspace ws-qfXwUv6LkzLXMAz1: resource not found
2020/09/30 18:51:10 [ERROR] module.origin.module.dreamcatcher: eval: *terraform.EvalSequence, err: Error retrieving workspace ws-qfXwUv6LkzLXMAz1: resource not found

Also the following 404s for each of them as well:

2020/09/30 18:51:10 [ERROR] module.origin.module.soothsayer: eval: *terraform.EvalRefresh, err: Error retrieving workspace ws-rnnmyj1dRNAt9Qxr: resource not found
2020/09/30 18:51:10 [ERROR] module.origin.module.soothsayer: eval: *terraform.EvalSequence, err: Error retrieving workspace ws-rnnmyj1dRNAt9Qxr: resource not found
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: 2020/09/30 18:51:10 [DEBUG] TFE API Response Details:
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: ---[ RESPONSE ]--------------------------------------
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: HTTP/2.0 404 Not Found
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Content-Length: 49
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Cache-Control: no-cache
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Content-Type: application/vnd.api+json; charset=utf-8
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Date: Wed, 30 Sep 2020 18:51:10 GMT
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Tfp-Api-Version: 2.3
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Vary: Accept-Encoding
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: Vary: Origin
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Content-Type-Options: nosniff
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Frame-Options: SAMEORIGIN
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Ratelimit-Limit: 30
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Ratelimit-Remaining: 13
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Ratelimit-Reset: 0.541
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Request-Id: 64ea7448-8d76-dc73-baa8-10d424c849e8
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: X-Xss-Protection: 1; mode=block
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: 
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: {
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:  "errors": [
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:   {
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:    "status": "404",
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:    "title": "not found"
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:   }
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4:  ]
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: }
2020-09-30T18:51:10.469Z [DEBUG] plugin.terraform-provider-tfe_v0.21.0_x4: -----------------------------------------------------

@engd
Copy link

engd commented Sep 30, 2020

I was able to work around it by removing workspaces manually with terraform state rm <module-name>. Thanks @im2nguyen for your help.

@im2nguyen
Copy link
Contributor Author

Hi @engd , can you show which resource is refreshing its state? The line should look similar to the following and come slightly before the --[ RESPONSE ]-----

tfe_variable.aws_access_key_id: Refreshing state... [id=var-2pcj9asdfasdfasd]

@im2nguyen im2nguyen changed the title Set varible id to null if workspace id doesnt exist Set variable id to null if workspace id doesnt exist Oct 1, 2020
Copy link
Contributor

@koikonom koikonom left a comment

Choose a reason for hiding this comment

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

LGTM

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

3 participants