BUG/MEDIUM: edge: avoid setting state until success #221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It was recently reported by @sloh-fastly that if a
sigsci_edge_deployment
was created without asigsci_site
it appeared to have been created within Terraform state. This caused some weird inconsistencies and could lead to the below error: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 toCreateOrUpdateEdgeDeployment()
andCreateOrUpdateEdgeDeploymentService
were sucessful.This fixes the underlying issue and avoids populating the Terraform state with tainted versions of
sigsci_edge_deployment
andsigsci_edge_deployment_service
if an error occurred.