-
Notifications
You must be signed in to change notification settings - Fork 159
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
Incorrect tags applied when tag is empty #2895
Comments
This appears to be an upstream issue hashicorp/terraform-provider-aws#31941 Pulumi versions affected:
Repro in TF:
terraform apply followed by
observe no tags reported. |
I've been diving deeper here since Pulumi reimplements tags + default tags merging; however this does not seem to be affecting this bug. This function: https://github.com/hashicorp/terraform-provider-aws/blob/master/internal/service/s3/bucket.go#L701 Receives different values for tags_all dependent on the presence of an empty-valued tag.
The incorrect empty tags_all value makes the upstream provider skip updating tags in the cloud because it fails to observe tags_all changing (empty = empty). |
Quick notes on why tags_all is empty in one case and not the other.
|
t0yv0/terraform-provider-aws#1 I've been looking at surgically editing SetTagsDiff and put it under test. I think what I am seeing is that there are serious issues in schema.ResourceDiff that conflate empty values with unknowns. An educated guess here is that the complicated code is trying to compensate for state transitions with unknowns, but it's not getting it right for empty values. My attempts to edit it so far hit other footguns in the TF Plugin SDK V2. |
Given that surgical fixes to SetTagsDiff run into some fundamental issues with TF Plugin SDK V2 confusing empty values with unknown, I'm evaluating a more brute-force approach in parallel. I've built another matrix #2932 that runs state transitions on a random sample of interesting tag states and compares expected vs actual. I've then attempted the following changes:
The end-result is passing a lot more, but not all, of the cases. The remaining failing cases can be summarized as "cannot add empty tag":
There is some remaining work to understand why adding an empty tag does not correctly recognize the need to update. |
I've pursued this approach further, and there appears to be at least one bug in the bridge; with the appropriate fix #2944 is passing 100 randomly drawn tags state transition tests including adding/removing empty tags. I'm now waiting for CI to qualify this with all the other tests, then submit for review. |
Updates. CI uncovered a number of issues but is now passing the 100 random test matrix. The remaining issues flagged by failing test pertain go supporting Plugin Framework resources correctly and avoiding secret leaks, handling unknown correctly for tags. I will be looking at those next. |
Updates. Using pulumi/pulumi-terraform-bridge@ed35c1e as the preferred fix for empty tag handling. Fixed unknown tests and secrets tests via another bridge fix pulumi/pulumi-terraform-bridge#1503 What's remaining is making sure Plugin Framework based resources are handled correctly. |
Fixes #2895 Requires a bridge change, currently still pre-release: pulumi/pulumi-terraform-bridge@v3.63.2...1e955db Due to confusing empty values with missing values at several layers of the stack, working with empty tag values was problematic before this change both in the Pulumi provider and in the upstream provider; this is now fixed by: - removing SetTagsDiff customizer from upstream; it is not working correctly for empty tags - similarly, removing tags_all computation for Plugin Framework based resources - completely taking over tagsAll handling from the TF layer to Pulumi layer; tagsAll is no longer marked as computed when working with TF (TF no longer sees it as computed), instead Pulumi computes tagsAll as a copy of tags and passes it down - fixing a bridge bug that ignored adding an empty tag (incorrect DIFF_NONE) This is change is now passing an aggressive random-sampled state transition matrix for various combinations of provider-level and resource-level tags.
Looks like automation closed this before a release went out. Reopening until we can release. |
Additional upgrade tests were requested before releasing (https://github.com/pulumi/home/issues/3130) to mitigate the risk of pulumi/pulumi-terraform-bridge#1502 bridge XSkipDetailedDiffForChanges flag required for this fix to work. |
Fixed in v6.9.0. |
What happened?
Customer reports a regression where having an empty tag value causes all tags to disappear with 6.5.x version of the provider (I also reproduced on 6.2.x).
This program:
pulumi up produces an empty tags export. Commenting out
cust_app
with empty string makes it produce 2 tags.Example
See above.
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: