-
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
Consider rewriting makeDetailedDiff #1895
Comments
Note that a prerequisite here is rolling out That could be an upside too - any changes here would already be flagged behind PlanResourceChange. related: #1785 Linking in the plugin-sdk patch which we added in order to support PlanResourceChange: pulumi/terraform-plugin-sdk#35 - that was partly motivated by the way we do DetaileDiff in the bridge We might also want to put in a bit of work in #1867 to be more confident in any changes we ship to detailedDiff - otherwise we'd likely be stuck with an unending resource-by-resource rollout. |
With AWS 3880 there is some evidence (derivation in #1917) that sometimes TF has entries in the InstanceDiff.Attributes while still planning to take the resource to the end-state that is identical to the original state. IN these cases, TF does not display a diff but Pulumi does. The root cause here remains unfixed (#1895) - Pulumi bridge is editing terraform-pulgin-sdk to expose the InstanceDiff structure to connect it to the makeDetailedDiff machinery. Pulumi should, like TF, stick to the gRPC protocol and rely only on the PlannedState value. We can incrementally approach the desired behavior with this change though which detects PlannedState=PriorState case and suppresses any diffs in this case. Fixes: - pulumi/pulumi-aws#3880 - pulumi/pulumi-aws#3306 - pulumi/pulumi-aws#3190 - pulumi/pulumi-aws#3454 --------- Co-authored-by: Venelin <[email protected]>
Actually indeed, looks like this one I wrote a bit later so it has my latest understanding but the ask is the same as in #1504. We should be able to write a much better detailedDiff now. |
Note that the proposal here is not only for detailed diff - the same algorithm influences if we return DIFF_SOME or DIFF_NONE to the engine, so the name is a bit misleading. pulumi-terraform-bridge/pkg/tfbridge/diff.go Lines 379 to 382 in ddb54e8
|
It shouldn't influence result, indeed, once we're done here. |
This adds integration tests around detailed diff for string, list, set and map attributes. Quite a few issues with: - Handling empty collections being removed/added - these are not shown in most cases - Adding/removing elements being duplicated in the detailed diff output - Outright wrong diff for `set element removed middle` and `set element added front` similar to #2103 Opened follow-up issues: - [Detailed diff empty collection diffs not shown](#2233) - [Detailed diff duplicated collection diffs](#2234) - [Detailed diff for set element changes shows more additions/removals than present](#2235) Related to #1895
This issue has been addressed in PR #2405 and shipped in release v3.92.0. |
Hello!
Issue details
Consider rewriting makeDetailedDiff logic that populates detailedDiff.
Desired properties
Why the current implementation cannot deliver the desired properties
This is elaborated in #1501 - essentially the current
implementation is trying to inspect a difficult to work with InstanceDiff object by doing 3 passes over news and olds
projection to TF. This works for the happy case but it does not faithfully hit the keys that may be changed by the TF
planning phase if they are not present in the union of Pulumi olds and news, and it creates confusion for changes
involving paths to set elements that are projected to Pulumi.
How can a new implementation look like
The suggested replacement is to compute the diff directly on Pulumi level (comparing PropertyValue representations of
resource state). Ideally this would take the exact same logic that Pulumi CLI uses to diff two PropertyValue instances
when the CLI is in charge of the diff completely.
What makes bridged providers special is that there is the underground phase of doing PlanResourceChange together with TF
that cannot be cleanly exposed to the engine in the current provider protocol. As a result bridged providers partially
take over the responsibility for the diffs and in particular detailed diffs and ignore changes.
This can still be made to work in the following way:
as is already done, compute planned state (via PlanResourceChange); this phase should continue taking care of
ignoreChanges at a semantic level
translate this planned state back to the PropertyValue domain
elaborate the difference between old state PropertyValue and the planned state PropertyValue at Pulumi level without
any further reference to the underlying TF provider schema
This implementation will avoid working with InstanceDiff object, work entirely at Pulumi level and be WISYWIG-defensible at Pulumi level, and support ignoreChanges.
Downsides
Changs involving sets will still involve confusing reordering of list elements in the Pulumi projection. I believe there is no universally good way currently to surface set diffs without making changes to Pulumi CLI diff display to cooperate a little bit better when displaying these changes, although partial solutions may be possible - heuristics that improve a lot of common cases.
Issues
#1501
#186
#1245
#752
#1867
#1756
Affected area/feature
The text was updated successfully, but these errors were encountered: