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

BUG/MEDIUM: edge: avoid setting state until success #221

Conversation

daniel-corbett
Copy link
Collaborator

It was recently reported by @sloh-fastly that if a sigsci_edge_deployment was created without a sigsci_site it appeared to have been created within Terraform state. This caused some weird inconsistencies and could lead to the below error:

Error: Provider produced inconsistent result after apply

When applying changes to sigsci_site.acme_nginx_waf["stg"], provider
"provider[\"registry.terraform.io/signalsciences/sigsci\"]" produced an
unexpected new value: Root resource was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Shu provided a thorough outline to reproduce, unfortunately I was not able to reproduce. However, I was able to identify what I believe to be happening. It seemed that even though the sigsci_edge_deployment was failing it was being populated into the terraform.tfstate file with a "tainted" status attached.

It was found that the provider was prematurely calling d.SetId() without first checking if an error had occurred. This was causing Terraform to believe that it at least partially succeeded warranting it to be in a tainted state.

This commit moves d.SetId() to only be called if the calls to CreateOrUpdateEdgeDeployment() and CreateOrUpdateEdgeDeploymentService were sucessful.

This fixes the underlying issue and avoids populating the Terraform state with tainted versions of sigsci_edge_deployment and sigsci_edge_deployment_service if an error occurred.

It was recently reported by @sloh-fastly that if a
`sigsci_edge_deployment` was created without a `sigsci_site` it appeared
to have been created within Terraform state. This caused some weird
inconsistencies and could lead to the below error:

```
Error: Provider produced inconsistent result after apply

When applying changes to sigsci_site.acme_nginx_waf["stg"], provider
"provider[\"registry.terraform.io/signalsciences/sigsci\"]" produced an
unexpected new value: Root resource was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.
```

Shu provided a thorough outline to reproduce, unfortunately I was not
able to reproduce. However, I was able to identify what I believe to be
happening. It seemed that even though the `sigsci_edge_deployment` was
failing it was being populated into the terraform.tfstate file with a
"tainted" status attached.

It was found that the provider was prematurely calling `d.SetId()`
without first checking if an error had occurred. This was causing
Terraform to believe that it at least partially succeeded warranting it
to be in a tainted state.

This commit moves `d.SetId()` to only be called if the calls to
`CreateOrUpdateEdgeDeployment()` and `CreateOrUpdateEdgeDeploymentService`
were sucessful.

This fixes the underlying issue and avoids populating the Terraform
state with tainted versions of `sigsci_edge_deployment` and
`sigsci_edge_deployment_service` if an error occurred.
@daniel-corbett daniel-corbett merged commit 48e03db into signalsciences:main May 2, 2024
2 checks passed
@daniel-corbett daniel-corbett deleted the dcorbett/bug-fix-edge-root-errors branch May 2, 2024 13:58
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

2 participants