-
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
Normalize Read result for empty collections #2069
Conversation
This workaround is aimed to reduce dirty refresh incidence on diffs between empty and null collections that is benign in TF but projects worse to Pulumi.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2069 +/- ##
==========================================
- Coverage 61.21% 61.20% -0.01%
==========================================
Files 337 337
Lines 45177 45200 +23
==========================================
+ Hits 27654 27666 +12
- Misses 16003 16013 +10
- Partials 1520 1521 +1 ☔ View full report in Codecov by Sentry. |
At this point it's making TestAccBucketPy pass dirty refresh check in AWS. The change has to be scoped down to PlanResourceChange path because rolling it out generally in the bridge introduces more dirty refresh than we had before. This is pretty interesting, we might need to go super-surgical. @VenelinMartinov suggested the correction may only be needed for maps, let me check lists and sets shortly. |
continue | ||
} | ||
|
||
if _, ok := sch.Elem.(*schema.Resource); ok || sch.ConfigMode == schema.SchemaConfigModeBlock { |
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.
What's the best way to decide if it's a block or attr these days @VenelinMartinov
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.
You can get the attributes of a resource from res.CoreConfigSchema().Attributes
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.
Something like this:
sch := res.CoreConfigSchema()
for key, attr := range sch.Attributes {
if !attr.Type.IsCollectionType() {
continue
}
if config.IsSet(key) {
continue
}
stateVal, ok := m[key]
if !ok {
continue
}
if !(stateVal.Type().IsCollectionType() && !stateVal.IsNull() && stateVal.LengthInt() == 0) {
continue
}
m[key] = cty.NullVal(attr.Type)
}
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've continued this in #2065
Guessing based on the investigation in #2063 that this needs to be scoped to non-computed collections. The best end to end test here would be to cover the idea that we get a clean refresh for these attributes. |
// To compensate for this problem, this method corrects the Pulumi Read result during `pulumi refresh` to also erase | ||
// empty collections from the Read result if the old input is missing or null. | ||
// | ||
// This currently only handles top-level properties. |
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 likely need to handle this for every block, right
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.
Sounds like it, but I don't have an e2e example handy.
Closing in favor of #2073 |
This workaround is aimed to reduce dirty refresh incidence on diffs between empty and null collections that is benign in TF but projects worse to Pulumi.