这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix TTL zero value handling in compute backend service #14239

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ruchikawa
Copy link

@ruchikawa ruchikawa commented Jun 11, 2025

Add send_empty_value: true to TTL fields (defaultTtl, maxTtl, clientTtl) to ensure zero values are included in API requests rather than being treated as empty and omitted.

This resolves the issue where setting client_ttl=0 would cause the API to apply its default value of 3600, leading to validation errors when combined with lower max_ttl values.

Also adds test case to verify TTL zero value behavior works correctly.

Fixes: hashicorp/terraform-provider-google#21632

compute: fixed `client_ttl`, `default_ttl`, and `max_ttl` fields in `google_compute_backend_service` and `google_compute_region_backend_service` not being sent to API when set to 0, which caused the API to apply default values and potentially trigger validation errors```

Add send_empty_value: true to TTL fields (defaultTtl, maxTtl, clientTtl)
to ensure zero values are included in API requests rather than being
treated as empty and omitted.

This resolves the issue where setting client_ttl=0 would cause the API
to apply its default value of 3600, leading to validation errors when
combined with lower max_ttl values.

Also adds test case to verify TTL zero value behavior works correctly.

Fixes: hashicorp/terraform-provider-google#21632
Copy link

google-cla bot commented Jun 11, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 11, 2025
@ruchikawa ruchikawa marked this pull request as ready for review June 12, 2025 14:13
@github-actions github-actions bot requested a review from roaks3 June 12, 2025 14:14
Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@roaks3, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

Copy link

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

I'm curious to see how the tests handle this, but I'm wondering a bit about the use of default_from_api and send_empty_value together, specifically for users already using the resource without these values set. For example, would they see a diff to change client_ttl to 0 instead of the default 3600 they had previously?

@modular-magician modular-magician added service/compute-l7-load-balancer and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Jun 17, 2025
@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 ( 2 files changed, 56 insertions(+), 3 deletions(-))
google-beta provider: Diff ( 2 files changed, 56 insertions(+), 3 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 1225
Passed tests: 1138
Skipped tests: 83
Affected tests: 4

Click here to see the affected service packages
  • compute
#### Action taken
Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeBackendService_backendServiceCacheIncludeHttpHeadersExample
  • TestAccComputeBackendService_backendServiceCacheSimpleExample
  • TestAccComputeBackendService_withCdnPolicy
  • TestAccComputeBackendService_withCdnPolicyTtlZero

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccComputeBackendService_backendServiceCacheSimpleExample [Debug log]
TestAccComputeBackendService_withCdnPolicy [Debug log]
TestAccComputeBackendService_withCdnPolicyTtlZero [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


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

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@ruchikawa
Copy link
Author

Thank you for the review. I overlooked the concern you raised. I also confirmed that while the tests ran, they're now failing with errors. Since I can't access the detailed error logs, I'll investigate this again in my local environment.
Please give me some time to confirm.

@github-actions github-actions bot requested a review from roaks3 June 19, 2025 05:38
Copy link

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

@GoogleCloudPlatform/terraform-team @roaks3 This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

Adding comment to clear the review request

Copy link

github-actions bot commented Jul 9, 2025

@ruchikawa, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

Copy link

@ruchikawa, this PR is waiting for action from you. If no action is taken, this PR will be closed in 14 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

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.

google_compute_backend_service cdn_policy.client_ttl can not change > 0 to 0
3 participants