-
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
Move property path code to separate file #2497
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2497 +/- ##
=======================================
Coverage 62.74% 62.74%
=======================================
Files 382 383 +1
Lines 51545 51552 +7
=======================================
+ Hits 32341 32348 +7
Misses 17392 17392
Partials 1812 1812 ☔ View full report in Codecov by Sentry. |
VenelinMartinov
changed the title
move property path code to separate file
Move property path code to separate file
Oct 17, 2024
…vvm/refactor_move_property_path
iwahbe
approved these changes
Oct 18, 2024
t0yv0
reviewed
Oct 18, 2024
t0yv0
approved these changes
Oct 18, 2024
…refactor_make_detailed_diff_to_short_circuit
…ctor_make_detailed_diff_to_short_circuit
…vvm/refactor_move_property_path
Base automatically changed from
vvm/refactor_make_detailed_diff_to_short_circuit
to
master
October 29, 2024 17:36
VenelinMartinov
added a commit
that referenced
this pull request
Oct 30, 2024
This change adds improved TF set handling to the detailed diff v2. The main challenge here is that pulumi does not have native sets, so set types are represented as lists. ### Diffing sets using the hash ### To correctly find the diff of two sets we calculate the hash of each element ourselves and do the diffs based on that. What makes this somewhat non-trivial is that due to MaxItemsOne flattening we can't just hash the pulumi `PropertyValue`s given to us by the engine. Instead we use `makeSingleTerraformInput` to transform the values using the schema. We then use the hashes of the elements in the set to calculate the diffs. This allows us to correctly account for shuffling and duplicates, matching the terraform behaviour of sets. When returning the element indices back to the engine, we need to return them in terms of oldState and newInputs because the engine does not have access to the plannedState (see #2281). To do that we keep the newInputs and match plannedState elements to their newInputs index by the set hash. Note that this is not possible if the set element contains any computed properties - these can change during the planning process, so we do not attempt to match and print a warning about possibly inaccurate diff results instead. ### Unknowns in sets ### Note that the terraform planning process does not allow a set to contain any unknowns, because that breaks the hashing. Because of that plan should always return an unknown for a set which contains any unknowns. This accounts for cases where resolving the unknown can result in duplicate elements. Unknown elements in sets - the whole set becomes unknown in the plan, so the algorithm no longer works. Currently we return an update for the whole set to the engine and it does the diff on its side. ### Testing ### This PR also includes tests for the set behaviour, both unit tests for the detailed diff algorithm and integration tests using pulumi programs for: - Single element additions, updates and removals - Shuffling, also with additions, updates and removals - Multi-element additions, updates and removals - Unknowns ### Issues ### Builds on #2405 Stacked on #2515, #2516, #2496 and #2497 fixes #2200 fixes #2300 fixes #1904 fixes #186
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pure refactor and just moves the propertyPath-related code to a new file. This is a separate PR to make reviewing easier.
Stacked on #2515, #2516 and #2496