Skip to content

compute: fix omission of explicit 0 values in BackendService cdn_policy TTLs#18103

Draft
burczyk wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
burczyk:fix-backend-service-zero-ttl
Draft

compute: fix omission of explicit 0 values in BackendService cdn_policy TTLs#18103
burczyk wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
burczyk:fix-backend-service-zero-ttl

Conversation

@burczyk

@burczyk burczyk commented Jun 26, 2026

Copy link
Copy Markdown
Member

This PR fixes a bug where explicitly setting default_ttl, max_ttl, or client_ttl to 0 inside the cdn_policy block of google_compute_backend_service or google_compute_region_backend_service resulted in the value being omitted from the JSON payload sent to the API (zero-value omission), causing the API to apply its own defaults instead of the requested 0.

Changes:

  1. Added send_empty_value: true to defaultTtl, maxTtl, and clientTtl fields in both BackendService.yaml and RegionBackendService.yaml. This ensures that explicit 0 values are preserved in the JSON payload instead of being skipped by tpgresource.IsEmptyValue.

  2. Added two new acceptance tests to verify this behavior:

  • backend_service_cache_zero_ttl: Verifies explicit 0 values are sent and preserved.
  • backend_service_cache_omitted_ttl: Verifies that omitting the fields (complimentary behavior) still works as expected (omitted from payload, allowing API defaults).

Linked Issues:
Fixes https://issuetracker.google.com/issues/498433517

Release Note Template for Downstream PRs (will be copied)

compute: fixed omission of explicit `0` values for `default_ttl`, `max_ttl`, and `client_ttl` in `cdn_policy` for `google_compute_backend_service` and `google_compute_region_backend_service`

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 26, 2026
@burczyk burczyk force-pushed the fix-backend-service-zero-ttl branch from 15eb3ac to 8edc923 Compare June 26, 2026 13:06
@burczyk burczyk force-pushed the fix-backend-service-zero-ttl branch from 335d5f4 to 5218a37 Compare June 26, 2026 14:12
@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 26, 2026
@modular-magician

modular-magician commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

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

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 4 files changed, 178 insertions(+), 6 deletions(-)
google-beta provider View Diff 4 files changed, 178 insertions(+), 6 deletions(-)
terraform-google-conversion View Diff 5 files changed, 18 insertions(+), 12 deletions(-)
Open in Cloud Shell View Diff 8 files changed, 238 insertions(+)

Test report

Analytics

Total Tests Passed Skipped Affected
1509 1409 94 6
Affected Service Packages
  • compute

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 6 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_backendServiceCacheOmittedTtlExample
  • TestAccComputeBackendService_backendServiceCacheSimpleExample
  • TestAccComputeBackendService_backendServiceCacheZeroTtlExample
  • TestAccComputeBackendService_withCdnPolicy
  • TestAccComputeRouterPeer_UpdateMd5AuthenticationKey

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
✅ Log TestAccComputeBackendService_backendServiceCacheOmittedTtlExample
✅ Log TestAccComputeBackendService_backendServiceCacheSimpleExample
✅ Log TestAccComputeBackendService_backendServiceCacheZeroTtlExample
✅ Log TestAccComputeBackendService_withCdnPolicy
✅ Log TestAccComputeRouterPeer_UpdateMd5AuthenticationKey
❌ Error · Log - TestAccComputeBackendService_backendServiceCacheIncludeHttpHeadersExample

Caution

Issues requiring attention before PR completion

🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the recording VCR build log or the debug logs folder for detailed results.

@burczyk VCR tests complete for 5218a37!

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