-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Unchanged nested TypeSet fields lost in state during diff/update #19658
Comments
Hi @rileykarson, Thanks for filing the issue. Unfortunately I'm not able to verify this locally at the moment, the acc test account I have access to is reporting over quota. However, I'm also not able to replicate this manually with nested sets, or like in this case, a list of sets. I suspect there could be some interaction with a SetFunc, or DiffSuppressFunc too. Can you show the raw data that The core dependencies are out of sync in vendor directory in that branch (you should have the same release of all terraform packages), so I would start by syncing those with the latest release and trying again. I'm not sure if the ACC tests in the provider have been updated yet (they might not require anything), but testing against terraform master may be worthwhile as well. |
Hey @jbardin! We're vendoring |
I think this is actually working correctly. For example, starting with
The zone is initially created with the two correct URLs:
And the POST is done with the right values:
Now when we update the second network from
Terraform wants to do the right thing:
Which due to the Set logic is deleting However, the "deletion" of
Due to PATCH semantics, we go from It appears to me that the PATCH call will always need to have all networks, so in this case I'm not sure we'll be able to support this with a Set. |
Based on my testing the other day, the problem is a bit before we make the We perform @drebes: Let me know if that makes sense/satisfies you! We're updating our SDK as soon as we're back from the long weekend, I'll update this again once I've tested with that vendored. |
If the |
Hi @rileykarson, If you have a chance, can you run this against TF master again? I quickly tried to verify it but that test wasn't in the main branches. However, all the |
I'm seeing the same behaviour, the test is new unfortunately! (we'd decided to block merging until it was fixed) I pushed the branch I tested with, it's at hashicorp/terraform-provider-google-beta#403 Update
Update state change from debug logs during the test:
|
Thanks @rileykarson, This actually shows a change now. I'll investigate why |
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. |
Terraform Version
Terraform Configuration Files
My schema contains a
TypeList
with aTypeSet
inside of it; I've put 2 objects in thatTypeSet
. Plan is idempotent after Create. When I update from 2 items -> 1, -> 0, or to 2 different objects, Terraform has behaved correctly.When I update from 2 -> 2 objects, and one of them is the same, Terraform loses the object that remained the same. From then on, Terraform is no longer idempotent. It shows the error under the "Actual Behaviour" header below, and each apply will only contain the (alternating) changed field.
Debug Output
I can provide full logs if needed. Relevant snippet at https://gist.github.com/rileykarson/673de95f0684671bdb2aadc76ed58d52. You can see that a GET from the API returns 2 entities & records them properly in state, a correct plan diff is shown & then the PATCH request has only 1 network. I can confirm this is from d.Get after verifying with log statements.
Expected Behavior
Doing a d.Get returns both
networks
blocksActual Behavior
Doing a d.Get returned only a single block
Steps to Reproduce
on hashicorp/terraform-provider-google-beta#229
Alternatively,
terraform init
terraform apply
terraform apply
Additional Context
I tried this with a top-level
TypeSet
and it worked correctly. It's entirely possible that the error has nothing to do with nesting and it was just this one that triggered the issue, but I suspect nesting is the problem.References
Maybe https://github.com/hashicorp/terraform/issues/8892 and #8891? The fix is from 2016, so it should definitely be included.
The text was updated successfully, but these errors were encountered: