-
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
Refactor makeTerraformInputs and friends #1725
Conversation
This reverts commit 6241673.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1725 +/- ##
==========================================
- Coverage 59.79% 59.45% -0.35%
==========================================
Files 300 309 +9
Lines 42025 42511 +486
==========================================
+ Hits 25129 25274 +145
- Misses 15474 15810 +336
- Partials 1422 1427 +5 ☔ View full report in Codecov by Sentry. |
The downstream checks revealed at least 2 new issues, which weren't known before, perhaps due to #1730 https://github.com/pulumi/pulumi-vault/actions/runs/8159199780/job/22303439815?pr=429 |
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 great, thank you very much. Conceptually this makes a lot of sense to me - the missing MaxItems=1 properties should be presenting as empty collections to the Terraform provider but not to the provider's validators. We have a slightly convoluted interaction with these validators already so the fix has to accommodate. This is really driving toward the correct behavior though! Let's do a pass to try to increase the longevity of the tests so we can still keep these tests around and understand what they're testing as the implementation itself evolves, this is an important property - left some style nits and suggestions, otherwise LGTM.
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 agree with all of t0yv0's comments.
I have a feeling this is used to set a default for the rulesets and that's the reason TF does not error out here. The resource https://github.com/hashicorp/terraform-provider-azurerm/blob/61ac20e312db3e460ccb2324fdc04bc9eb2e503e/internal/services/eventhub/eventhub_namespace_resource.go#L128 Note: I looked for the combination of attributes
It looks like it's used in a few places in Azure but SchemaConfigModeAttr is virtually unused in AWS. Will do a more in-depth comparison of the TF behaviour here with what the bridge does next week. |
Terraform docs on
which sounds very very relevant. |
Given the multiple rounds of different downstream regressions caused by the stages of this PR, combined with the slow iteration loop, I don't see how we can safely land this right now. Instead, I'd like to make the refactoring changes which were part of this PR and then make the behavioural changes once we can properly test them. Old description for posterity: This should allow us to address pulumi/pulumi-aws#3427 and unblock further upstream updates there. The issue was that TF seems to pass empty arrays for not-specified MaxItemsOne properties, while we were passing nil, resulting in differences in behaviour between the bridge and TF. The original PR went a bit too far and made the change for I've reused the mechanism added #1583 and only apply the empty arrays for MaxItemsOne properties in makeTerraformInputs when the This PR introduces a new |
I've opened #1767 for the follow up work. |
I was a bit uncomfortable at first but approving after our chat and another round of looking at it in detail. Behavior is not changing, some new code is added but it's flagged off, and new tests are added which is excellent. A bit of a nit but I'd prefer in the future not to remove public members Thanks for the substantial work on the foundations here! |
Thanks for the reviews! After discussing with @t0yv0, I've removed the breaking changes here - we really have no reason to do that. I've cleaned up other unnecessary changes from this PR and will merge once tests pass. |
Adds another regression test for #3421 The issue is not only present in Create but in Update - almost shipped a half-fix in pulumi/pulumi-terraform-bridge#1725. This test should ensure we don't ship a half-fix.
part of #1785 This change adds a normalisation step for collections when recovering cty values to pass to terraform. This ensures we represent them similarly to terraform. In practice this means that all block collections need to be passed to TF providers as an empty collection instead of nil. This should get rid of quite a few subtle discrepancies in the data we pass to the TF provider code. These sometimes result in panics since we pass unexpected nils. This gets rid of all known input discrepancies discovered so far through cross-testing. The full rules for what is a block are [here](https://github.com/hashicorp/terraform-plugin-sdk/blob/1f499688ebd9420768f501d4ed622a51b2135ced/helper/schema/core_schema.go#L60). It is essentially properties with schema: typeList or typeSet with a Resource Elem. fixes #1970 fixes #1915 fixes #1964 fixes #1767 fixes #1762 TODO: [DONE] remove the MaxItemsOne default hacks introduced in #1725 (opened #2049) --------- Co-authored-by: Anton Tayanovskyy <[email protected]> Co-authored-by: Ian Wahbe <[email protected]>
This PR refactors the various functions related to converting pulumi inputs to TF inputs.
It also exposes a new option when making inputs:
EnableMaxItemsOneDefaults
which will allow us to fix pulumi/pulumi-aws#3427 once we can properly test the changes.Opted not to land the behavioural changes for
EnableMaxItemsOneDefaults
yet because of the multiple rounds of varied downstream regressions - seems like we need to add a framework for testing against the TF behaviour in order to land this.