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

Make billing budget filter credit_types and subaccounts updatable #7035

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

zli82016
Copy link
Member

Fixes https://b.corp.google.com/issues/242945866

Make fields credit_types and subaccounts updatable

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

billingbudget: Make fields `credit_types` and `subaccounts` updatable for `google_billing_budget`

@zli82016 zli82016 requested review from a team and trodge and removed request for a team December 22, 2022 23:11
@modular-magician
Copy link
Collaborator

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

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a major release window. An override-breaking-change label can be added to allow merging.

Diff report

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

Terraform GA: Diff ( 4 files changed, 83 insertions(+), 11 deletions(-))
Terraform Beta: Diff ( 4 files changed, 83 insertions(+), 11 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2381
Passed tests 2126
Skipped tests: 248
Failed tests: 7

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccBillingSubaccount_renameOnDestroy|TestAccContainerCluster_withInvalidGatewayApiConfigChannel|TestAccBillingBudget_billingBudgetUpdate|TestAccBillingBudget_billingBudgetFilterExample|TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample|TestAccBillingBudget_billingFilterSubaccounts

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]
TestAccBillingSubaccount_renameOnDestroy[Debug log]
TestAccContainerCluster_withInvalidGatewayApiConfigChannel[Debug log]
TestAccBillingBudget_billingBudgetUpdate[Debug log]
TestAccBillingBudget_billingBudgetFilterExample[Debug log]
TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample[Debug log]
TestAccBillingBudget_billingFilterSubaccounts[Debug log]

All tests passed
View the build log or the debug log for each test

Copy link
Contributor

@trodge trodge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The breaking change detection is complaining because we're removing O+C from budget_filter.credit_types and budget_filter.subaccounts, but I can't figure out why these fields needed to be O+C in the first place. The overrides were added in #4273 but the test that was failing, TestAccBillingBudget_billingBudgetBasicExample, seemed to only require budget_filter and budget_filter.credit_types_treatment be O+C.

@@ -93,8 +93,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_flatten: 'templates/terraform/custom_flatten/object_to_bool.go.erb'
amount.specifiedAmount.currencyCode: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
budgetFilter.creditTypes: !ruby/object:Overrides::Terraform::PropertyOverride
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these overrides need to be removed to make the field updatable?

Copy link
Member Author

@zli82016 zli82016 Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without removing the overrides, the test testAccBillingBudget_billingBudgetCustomPeriodUpdate failed. https://github.com/GoogleCloudPlatform/magic-modules/pull/7035/files#diff-a5c0fe03fa3b54255bdca47bd1415a24c2de3ec1715a457db27a558bd0e1b530R114.

The error is "Credit types treatment of INCLUDE_ALL_CREDITS or EXCLUDE_ALL_CREDITS requires empty list of credit_types".

The reason is that creditTypes is sent to API because of the computed override even the user does not set that field in config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the response from API and the API does not return default values for the two fields. These two fields do not behave like computed fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be able to be fixed while retaining the computed property. Even though this is a mistake these changes will break end users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ScottSuarez , do you have an idea how to fix it while retaining the computed property?

@ScottSuarez
Copy link
Contributor

Even if a value does not need to be O+C.. A transition from O+C to O is breaking as terraform state is stored for the previously O+C field. So any subsequent apply will try to resolve the diff by removing any previous value.

@zli82016
Copy link
Member Author

zli82016 commented Jan 3, 2023

Is this change allowed to merge to main branch with the override-breaking-change label? Or it needs to wait for a major release?

@zli82016
Copy link
Member Author

zli82016 commented Jan 3, 2023

I tested with the config https://paste.googleplex.com/6534593615233024 and current provider. The config contains the field credit_types, which is one field in the PR from O+C -> O. And then build the new provider and do terraform plan. The plan is empty.

In this special case, is it not a breaking change?

@trodge
Copy link
Contributor

trodge commented Jan 3, 2023

I tested with the config https://paste.googleplex.com/6534593615233024 and current provider. The config contains the field credit_types, which is one field in the PR from O+C -> O. And then build the new provider and do terraform plan. The plan is empty.

In this special case, is it not a breaking change?

I think the case we want to test is one where budget_filters is specified but credit_types and subaccounts are not.

@zli82016
Copy link
Member Author

zli82016 commented Jan 3, 2023

I tested with the config https://paste.googleplex.com/6534593615233024 and current provider. The config contains the field credit_types, which is one field in the PR from O+C -> O. And then build the new provider and do terraform plan. The plan is empty.
In this special case, is it not a breaking change?

I think the case we want to test is one where budget_filters is specified but credit_types and subaccounts are not.

I also tested this case that credit_types and subaccounts are not set. The plan is also empty with the new provider.

@ScottSuarez
Copy link
Contributor

I tested with the config paste.googleplex.com/6534593615233024 and current provider. The config contains the field credit_types, which is one field in the PR from O+C -> O. And then build the new provider and do terraform plan. The plan is empty.
In this special case, is it not a breaking change?

I think the case we want to test is one where budget_filters is specified but credit_types and subaccounts are not.

I also tested this case that credit_types and subaccounts are not set. The plan is also empty with the new provider.

I can confirm. Also tested this scenario

@zli82016
Copy link
Member Author

zli82016 commented Jan 10, 2023

In this PR, C + O of fields credit_types and subaccounts are changed to O. I tested the following cases with built provider and do not see diff for terraform plan.

It looks like it is because the fields don't behave like computed and don't have default values in API side, the changes from C + O -> C is not breaking.

@zli82016
Copy link
Member Author

zli82016 commented Jan 11, 2023

Talked with @ScottSuarez , as the change from C + O to O is a breaking change, we will keep Computed property now. To remove the fields credit_types and subaccounts in the config, the user has to set the fields to be an empty array in the config as the workaround.

Created a bug hashicorp/terraform-provider-google#13456 and we need to remove Computed for these fields in the next major release.

@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.

Terraform GA: Diff ( 4 files changed, 139 insertions(+), 12 deletions(-))
Terraform Beta: Diff ( 4 files changed, 139 insertions(+), 12 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@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.

Terraform GA: Diff ( 4 files changed, 139 insertions(+), 12 deletions(-))
Terraform Beta: Diff ( 4 files changed, 139 insertions(+), 12 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2404
Passed tests 2150
Skipped tests: 251
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccContainerCluster_withInvalidGatewayApiConfigChannel|TestAccBillingBudget_billingFilterSubaccounts|TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccContainerCluster_withInvalidGatewayApiConfigChannel[Debug log]
TestAccBillingBudget_billingFilterSubaccounts[Debug log]

Tests failed during RECORDING mode:
TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@zli82016 zli82016 requested a review from trodge January 11, 2023 23:51
Copy link
Contributor

@trodge trodge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants