-
Notifications
You must be signed in to change notification settings - Fork 44
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
Present clearer diff fo single element changes to sets #186
Comments
Another user affected: pulumi/pulumi-aws#2856 Also, there is another related issue here #1756 that goes beyond just presentation, currently the user is not able to use ignoreChanges to do-what-I-mean over such set element changes. |
Another repro of this with some debug details on why it's happening. #1894 - I think this is exactly the problem in pulumi/pulumi-aws#2095 |
Thinking about possible solutions here; one option would be to extend the CLI with special support in the detailedDiff to express "element added" vs "element removed" vs "element updated" changes irrespective of numeric index in a set. If we do not change the CLI interface, I am thinking we could still make progress if we drop the assumption that the numeric indices [0..3] mean anything related to the program positions. This would work as follows. Suppose we are changing from set type diff = array<changes<T>>
type change<T> = added(T) | removed(T) | changed(T, T) The invariant is that changes only happen at the same identity:
Then we can sort changes by Unfortunately I still don't have it worked out how to naturally interpret ignoreChanges in the setting #1756 - and a complete proposal should have an answer for that. The key difficulty is that ignoring changes may be affecting element identity. |
There is a subtlety that @corymhall points out that indicates my mental model of the set semantics above is not accurate. The .Set hash customizer acts not as an element key but indeed as identity. The following program is considered a no-change since all the former and new elements map to the same value func TestSetChanging(t *testing.T) {
skipUnlessLinux(t)
resource := &schema.Resource{
Schema: map[string]*schema.Schema{
"set": {
Type: schema.TypeSet,
Optional: true,
Set: func(i interface{}) int {
return 1
},
Elem: &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
},
}
runDiffCheck(t, diffTestCase{
Resource: resource,
Config1: map[string]any{
"set": []any{"A"},
},
Config2: map[string]any{
"set": []any{"B", "C"},
},
})
} Therefore it would seem There is a slight complication I recall, possibly tangential here but listing for completeness: TF treats sets of objects in a bit map-like fashion but it seems not quite tied to the Set function, coming from https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pkg/tfshim/sdk-v2/internal/tf/plans/objchange/objchange.go#L430 where objects inside a set are matched by non-computed attr-sets to propagate computed attrs in the planning phase. |
Another case reported by a customer: ... specifically around EC2 security group ingress. We have an array of security group rules specified (of type pulumi.Input<pulumi.Input<inputs.ec2.SecurityGroupIngress>[]>). I noticed that when we delete one rule, the diff is pretty confusing because the array is unordered. It is difficult to see what was actually deleted in the diff because it rearranges every single rule in the update. |
@mjeffryes @iwahbe per a conversation with @lukehoban I'm convinced we need a gRPC protocol change to accommodate this and other TF impedance mismatch, there's a high barrier to these though so we'll need to take some time to iterate on a proposal and some prototyping. |
This issue has been addressed in PR #2451 and shipped in release v3.94.0. |
Currently, when a single item in a set has a diff, we show every item of the set having changed places.
For example - in the diff below (from pulumi/pulumi-aws#920) - there is one element actually changing (
IamInstanceProfile
's value is changing from an id to an ARN) - but all other elements are getting mixed up:The text was updated successfully, but these errors were encountered: