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

google_compute_backend_service: Disabling 'serve_while_stale' not persisting #9526

Closed
QuentinMoss opened this issue Jul 8, 2021 · 2 comments
Labels

Comments

@QuentinMoss
Copy link

QuentinMoss commented Jul 8, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

v1.0.2

Affected Resource(s)

  • google_compute_backend_service

Terraform Configuration Files

Module code for CDN

....
      signed_url_cache_max_age_sec = lookup(local.safe_cdn_policy, "signed_url_cache_max_age_sec", var.cache_key_policy == null ? null : 0)
      default_ttl                  = lookup(local.safe_cdn_policy, "default_ttl", null)
      max_ttl                      = lookup(local.safe_cdn_policy, "max_ttl", null)
      client_ttl                   = lookup(local.safe_cdn_policy, "client_ttl", null)
      cache_mode                   = lookup(local.safe_cdn_policy, "cache_mode", "USE_ORIGIN_HEADERS")
      serve_while_stale            = lookup(local.safe_cdn_policy, "serve_while_stale", 0)
      # Negative caching appears to not be supported in the provider. This needs to be disabled manually to persist.
      negative_caching = lookup(local.safe_cdn_policy, "negative_caching", null)

      dynamic "negative_caching_policy" {
        for_each = coalesce(var.negative_caching_policies, [])
        content {
          code = lookup(negative_caching_policy.value, "code", null)
          ttl  = lookup(negative_caching_policy.value, "ttl", null)
        }
      }
    }
  }

Resource:

module "issue-example-backend-services" {
  source = "../../modules/gce_backend_services"
  name   = "issue_example"
  cdn    = true

  cdn_policy = {
    serve_while_stale = 0
  }
  cache_key_policy = {
    include_host         = true
    include_protocol     = true
    include_query_string = true
  }

  clusters = [
    {
      node_pool = module.issue_example.node_pool
    }
  ]
  ....

Debug Output

Expected Behavior

In a situation where you want to disable 'serve_while_stale' by default, a value of 0 or null does not persist

  ~ resource "google_compute_backend_service" "default" {
        id                              = "srecluster-policy-bot"
        name                            = "srecluster-policy-bot"
        # (15 unchanged attributes hidden)


      ~ cdn_policy {
          ~ serve_while_stale            = 86400 -> 0
            # (6 unchanged attributes hidden)

            # (1 unchanged block hidden)
        }

        # (2 unchanged blocks hidden)
    }

Actual Behavior

The settings displayed in the plan output are not actually modified in state once executed, and the changes will be planned each time you run 'terraform plan'

Steps to Reproduce

  1. Configure a backend_service with CDN enabled, set serve_while_stale to 0, run apply twice and notice it will plan the same changes each time.

Important Factoids

References

  • #0000
@QuentinMoss QuentinMoss added the bug label Jul 8, 2021
@QuentinMoss QuentinMoss changed the title google_compute_backend_service: Disabling serve_while_stale' not persisting google_compute_backend_service: Disabling 'serve_while_stale' not persisting Jul 8, 2021
@QuentinMoss
Copy link
Author

This is fixed in 3.74.0 - apparently the provider didn't support these values as they were not GA (?)

@github-actions
Copy link

github-actions bot commented Aug 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-l7-load-balancer labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant