-
Notifications
You must be signed in to change notification settings - Fork 43
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
Accurate bridge previews trigger unnecessary replacements when adding and removing the same number of elements in a collection #2726
Comments
Can you shed some more light here the issue as described is very confusing.
|
Can you also add the expected behavior for Pulumi. Thanks. |
Thank you for the comments. I've updated the description to clarify. The pulumi preview does indicate a replacement with the The point about pulumi detailed diff being purely presentational is very good. I have #2674 for this and I've expanded that to include both directions (Detailed diff marks a non-existent replacement and Detailed diff does not correctly detect a replacement). |
This change adds SDKv2 detailed diff tests for top-level ForceNew sets. Some of the test permutations are skipped because we discovered some unnecessary replacements on our side. This is tracked in #2726
This adds Detailed Diff tests for the SDKv2 bridge for lists with ForceNew. Some of the tests are skipped because of #2726
This highly suspect and I'd like to understand the repro in pure Terraform. This is indicative of a Terraform bug but would be highly surprising. I'm poking around to try finding a few resources in AWS to see if I can reproduce at that level. For sets of strings this seems to actually generate replaces in AWS so this may be still scoped to sets of objects. |
|
Was able to reproduce with this snippet: data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "example" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
root_block_device {
volume_size = 8
}
ephemeral_block_device {
virtual_name = "ephemeral0"
device_name = "/dev/sde"
}
ephemeral_block_device {
virtual_name = "ephemeral3" # tweak this
device_name = "/dev/sdf"
}
} Getting:
|
I think it could be argued either way here - the counter-argument is that in this case, the collection was not modified but only the element property was changed. |
So semantically, setting ForceNew on the collection means that we'd like to replace the resource in case the number of elements in the collection changes. Modifying a property on an element in the collection does not "change" the collection. LMK what you think. |
I've found hashicorp/terraform-plugin-sdk#1314 but hashicorp/terraform#34691 is aged out. |
1314 seems more related to the schema validation which we had to work around in #2723 (comment) |
1314 is pertinent here because if TF picked a replace plan then 1314 wouldn't have been an issue it seems. |
Let's keep this one around to collect cross-links to actual user issues. Seems to be a very odd behavior but indeed present in TF. Very interesting find. |
This one was meant as an issue for "accurate previews does not match TF", which is fixed in #2747 I can open a new one for "TF (and we) do not replace resources when a nested property is updated on a ForceNew collection" |
Opened #2753 |
… diff is presentation-only (#2747) This change adds a fallback for the detailed diff replace decision. This ensures that the detailed diff is presentation only. If we fail to identify the reason for a replace in the detailed diff calculation we mark it against `__meta`, similar to what we did before: https://github.com/pulumi/pulumi-terraform-bridge/blob/a952164c556a86f46dac2ac34e915143cfd7abd8/pkg/tfbridge/provider.go#L1262 If we incorrectly identify a non-existent replace we demote it to an update/create/delete. This is flagged behind the Accurate Previews flag. fixes #2674 fixes #2726
What happened?
Under accurate bridge previews we now trigger replacements when we shouldn't for changes where the same number of elements was added and removed from a collection.
Example
For a set property with ForceNew on the set itself if we transition from
to
we get a replacement which is not triggered in TF:
Pulumi:
versus TF:
We should instead correctly mark only the nested property for update and no trigger a replacement on the resource.
See
TestDetailedDiffSet/block_top_level_force_new/same_element_updated_unordered
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: