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

allow 0 for negative_caching_policy.ttl #5099

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

edwardmedia
Copy link
Contributor

@edwardmedia edwardmedia commented Aug 16, 2021

Fixes hashicorp/terraform-provider-google#9805

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)

compute: fixed a bug where `negative_caching_policy` cannot be set always revalidate on `google_compute_backend_service`

@google-cla google-cla bot added the cla: yes label Aug 16, 2021
@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@c2thorn, please review this PR or find an appropriate assignee.

@edwardmedia
Copy link
Contributor Author

edwardmedia commented Aug 16, 2021

This behavior is only applied in global Backend Service ( regional Backend Service does not support cdn policy https://cloud.google.com/cdn#section-6 )

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))
Terraform Beta: Diff ( 2 files changed, 3 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@ljybar
Copy link

ljybar commented Aug 18, 2021

"0" still doesn't work for negative_caching_policy.ttl
google v3.80.0
google-beta v3.80.0

Code part:

resource "google_compute_backend_service" "ocom-ci-dev1-app-backsvc1" {
  name = "ocom-ci-dev1-app-backsvc1"
  provider = google-beta
  load_balancing_scheme = "EXTERNAL"
  backend {
    balancing_mode = "UTILIZATION"
    max_utilization = "0.9"
    group = google_compute_instance_group.ocom-ci-dev1-app-group1.id
  }
  backend {
    balancing_mode = "UTILIZATION"
    max_utilization = "0.9"
    group = google_compute_instance_group.ocom-ci-dev1-app-group2.id
  }
  health_checks = [
    google_compute_http_health_check.ocom-ci-dev1-app-hc1.id
  ]
  port_name = "http"
  protocol = "HTTP"
  timeout_sec = "86400"
  connection_draining_timeout_sec = "600"
  log_config {
    enable = true
    sample_rate = 1
  }
  enable_cdn = true
  cdn_policy {
    cache_mode = "USE_ORIGIN_HEADERS"
    cache_key_policy {
      include_host = true
      include_protocol = true
      include_query_string = true
    }
    serve_while_stale = 86400
    signed_url_cache_max_age_sec = 3600
    negative_caching = true
    negative_caching_policy {
      code = 501
      ttl = 0
    }
    negative_caching_policy {
      code = 404
      ttl = 0
    }
    negative_caching_policy {
      code = 451
      ttl = 0
    }
}

Error example:


`google_compute_backend_service.ocom-ci-dev1-app-backsvc1: Creating...

Error: Error creating BackendService: googleapi: Error 400: Invalid value for field 'resource.cdnPolicy.negativeCachingPolicy[0]': '{  "code": 501}'. Code and ttl must be specified in NegativeCachingPolicy., invalid

  on main.tf line 2785, in resource "google_compute_backend_service" "ocom-ci-dev1-app-backsvc1":
2785: resource "google_compute_backend_service" "ocom-ci-dev1-app-backsvc1" {
`

if the problem has already been resolved, what do I need to do to make the object creation work for me?

@c2thorn
Copy link
Member

c2thorn commented Aug 18, 2021

@ljybar This fix has not been released yet, and should be a part of v3.81.
If you need/want to try out the fix now, you could build the provider at this commit: f17f748 (#9821)

khajduczenia pushed a commit to khajduczenia/magic-modules that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create google_compute_backend_service object wit negative_caching_policy = always revalidate
4 participants