-
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
Pass PlannedPrivate
from PlanResourceChange to ApplyResourceChange
#2407
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2407 +/- ##
=======================================
Coverage 57.10% 57.11%
=======================================
Files 369 369
Lines 50593 50604 +11
=======================================
+ Hits 28891 28902 +11
Misses 20124 20124
Partials 1578 1578 ☔ View full report in Codecov by Sentry. |
The `PlannedPrivate` field of the PRC response includes metadata that's required for correctly re-assembling the diff. For example, it includes `NewExtra` which includes the original value for attributes with a `StateFunc`. Without `PlannedPrivate`, those attributes get saved to state encoded twice. This can lead to mangled data in state and perma-diffs.
852d21f
to
b807281
Compare
PlannedPrivate
from PlanResourceChange to ApplyResourceChange
pkg/tfbridge/provider_test.go
Outdated
@@ -5113,7 +5113,8 @@ func TestPlanResourceChangeUnknowns(t *testing.T) { | |||
"setBlockProps":[], | |||
"listBlockProps":[], | |||
"nestedListBlockProps":[], | |||
"maxItemsOneBlockProp":null | |||
"maxItemsOneBlockProp":null, | |||
"__meta":"{\"_new_extra_shim\":{}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this will cause pain somewhere else? I.e. re-recording of upgrade tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll likely have to fix a bunch of GRPC tests everywhere but that's fine.
PlannedMeta map[string]interface{} | ||
PlannedDiff *terraform.InstanceDiff | ||
PlannedState cty.Value | ||
PlannedPrivate map[string]interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually PlannedPrivate
not PlannedMeta. Renaming this so it aligns better with terraform
Is the third parameter on CreateContext/UpdateContext the PlannedPrivate in TF? If so, I think we can write cross-tests here similar to
|
Sadly it's not :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard for me to review, just because it's hard to know what the correct behavior is.
I'd leave this for @VenelinMartinov and @t0yv0 unless I need to spin up on this.
Where is the PlannedPrivate picked up on the TF side? Is there a way for us to hook into that and write a cross-test for that? That'd give us more confidence that we are matching the TF behaviour here. Don't want to block the PR on this since the changes look sensible but it'd be nice if we can be confident here. |
How does the TF provider access the PlannedPrivate? |
I was working with this on Florian a bit this morning, I can review. It looked safe enough but we were exploring how it's tangled to timeouts and there's a little bit of residual uncertainty I have around how TF handles timeout etc encoding in PlannedPrivate as well as whether we're doing a good job of mapping planned private to Pulumi protocol. It's a bit subtle. |
@VenelinMartinov It's reconstructing the The resource access methods (e.g. |
Maybe not without bigger changes - this property seems to be hidden from the provider too and only accessible from within the plugin-sdk. The provider only sees the .Get result change depending on if this is set or not. Is this correct? If so, then we'd need to add a hook in the plugin-sdk for this which is certainly out of scope here. |
@VenelinMartinov Yeah you're understanding is correct. It's hidden in the |
Cross-test would be very helpful if just to debug the TF side of things. |
Why couldn't we write a cross test that asserts on the results of .Get? We don't need a cross-test to assert the internals, only the provider visible section. |
Yeah, that bit is possible - a test like
Unfortunately that wouldn't cover the full contents of the |
@t0yv0 @VenelinMartinov I added a cross test, please have a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for digging in here!
This PR has been shipped in release v3.91.0. |
The
PlannedPrivate
field of the PRC response includes metadata that's required for correctly re-assembling the diff.For example, it includes
NewExtra
which includes the original value for attributes with aStateFunc
.Without
PlannedPrivate
, those attributes get saved to state encoded twice. This can lead to mangled data in state and perma-diffs.Fixes #2408