Skip to content
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

Show diff for computed nested labels fields when creating resources #10397

Closed

Conversation

zli82016
Copy link
Member

@zli82016 zli82016 commented Apr 9, 2024

Resource google_cloud_run_service and google_cloud_run_domain_mapping have nested labels fields metadata.0.labels and metadata.0.annotations.

In the CustomizeDiff function SetMetadataLabelsDiff, SetNew is applied on "metadata" field with the object including terraform_labels and effective_labels. It introduced two bugs.

  1. when creating resource, computed metadata.0.labels and metadata.0.annotations fields don't appear in terraform plan
  2. After creating the resource with the normal labels value, and then updating the labels fields with the computed value will fail, similar to root labels field Error: Provider produced inconsistent final plan - "registry.terraform.io/hashicorp/google" produced an invalid new value for .terraform_labels: new element "date_modified" has appeared. hashicorp/terraform-provider-google#16217.
    This bug cannot be fixed with the similar way in Fix the bug for computed labels and annotations #10182.
    The reason is that metadata.0.terraform_labels and metadat.0.effective_labels fields cannot be set to computed due to a bug that SetNew doesn't work on nested fields
    in terraform sdk SetNew does not work on nested fields hashicorp/terraform-plugin-sdk#459

The solution to fix these two bugs in my mind is to move terraform_labels and effective_labels to root level in provider release 6.0.
Before the release 6.0, the first bug can be fixed in this PR and I don't find an easy way to fix the second bug.

Release Note Template for Downstream PRs (will be copied)

cloudrun: fixed the bug that computed `metadata.0.labels` and `metadata.0.annotations` fields don't appear in terraform plan when creating resource `google_cloud_run_service` and `google_cloud_run_domain_mapping`

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 3 files changed, 87 insertions(+))
google-beta provider: Diff ( 3 files changed, 87 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2738
Passed tests: 2382
Skipped tests: 354
Affected tests: 2

Click here to see the affected service packages
all service packages are affected

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccCloudRunService_withComputedLabels|TestAccSqlUser_postgresIAM

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccCloudRunService_withComputedLabels[Debug log]

$\textcolor{red}{\textsf{Tests failed when rerunning REPLAYING mode:}}$
TestAccCloudRunService_withComputedLabels[Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccSqlUser_postgresIAM[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 3 files changed, 90 insertions(+))
google-beta provider: Diff ( 3 files changed, 90 insertions(+))

1 similar comment
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 3 files changed, 90 insertions(+))
google-beta provider: Diff ( 3 files changed, 90 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3267
Passed tests: 2899
Skipped tests: 367
Affected tests: 1

Click here to see the affected service packages
all service packages are affected

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccSqlUser_postgresIAM

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2784
Passed tests: 2426
Skipped tests: 356
Affected tests: 2

Click here to see the affected service packages
all service packages are affected

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataSourceGoogleServiceAccountJwt|TestAccSqlUser_postgresIAM

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccSqlUser_postgresIAM[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataSourceGoogleServiceAccountJwt[Debug log]

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccSqlUser_postgresIAM[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@zli82016 zli82016 closed this Apr 9, 2024
@zli82016 zli82016 deleted the computed-nested-labels-2 branch April 16, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants