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

Permadiff for failover_policy in google_compute_region_backend_service #10247

Assignees
Labels

Comments

@jeroenj
Copy link

jeroenj commented Oct 5, 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

Terraform v0.14.6
+ provider registry.terraform.io/hashicorp/google v3.86.0

Affected Resource(s)

  • google_compute_region_backend_service

Terraform Configuration Files

resource "google_project" "test" {
  name            = "test"
  project_id      = "test"
}

resource "google_compute_instance" "test" {
  name         = "test"
  project      = google_project.test.project_id
  machine_type = "e2-micro"
  zone         = "europe-west1-d"

  boot_disk {
    auto_delete = true

    initialize_params {
      type  = "pd-standard"
      size  = 10
      image = "ubuntu-os-cloud/ubuntu-2004-lts"
    }
  }

  network_interface {
    network = "default"

    access_config {
    }
  }
}

resource "google_compute_instance_group" "test" {
  name    = "test"
  project = google_project.test.project_id
  zone    = "europe-west1-d"

  instances = [google_compute_instance.test.self_link]
}

resource "google_compute_health_check" "test" {
  name    = "test"
  project = google_project.test.project_id

  http_health_check {
    port         = 80
    request_path = "/"
  }
}

resource "google_compute_region_backend_service" "test" {
  name                            = "test"
  project                         = google_project.test.project_id
  region                          = "europe-west1"
  protocol                        = "TCP"
  load_balancing_scheme           = "INTERNAL"
  network                         = "default"
  health_checks                   = [google_compute_health_check.test.self_link]
  connection_draining_timeout_sec = 60

  failover_policy {
    disable_connection_drain_on_failover = false
    drop_traffic_if_unhealthy            = false
    failover_ratio                       = 0
  }

  backend {
    group    = google_compute_instance_group.test.self_link
    failover = true
  }
}

resource "google_compute_forwarding_rule" "test" {
  name                  = "test"
  project               = google_project.test.project_id
  region                = "europe-west1"
  network               = "default"
  backend_service       = google_compute_region_backend_service.test.self_link
  load_balancing_scheme = "INTERNAL"
  ports                 = [80]
}

Debug Output

https://gist.github.com/jeroenj/ff25f6e513696bf88aaa3305d236433a

Expected Behavior

The backend service gets created with the desired failover_policy without showing a diff on it during a next plan.

Actual Behavior

The backend service gets created with the desired failover_policy. It's actually not creating the failover_policy explicitly since they equal to the default values. Because of that during a next plan the failover group shows up as a diff:

  # google_compute_region_backend_service.test will be updated in-place
  ~ resource "google_compute_region_backend_service" "test" {
        id                              = "projects/proxy-and-files-12f0de7a/regions/europe-west1/backendServices/test"
        name                            = "test"
        # (14 unchanged attributes hidden)


      + failover_policy {
          + disable_connection_drain_on_failover = false
          + drop_traffic_if_unhealthy            = false
          + failover_ratio                       = 0
        }
        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

There's actually two ways to get to this issue. The first one is to apply the config as noted above.

However it agreeable doesn't make much sense to set failover_policy when the settings defined are equal to the defaults in GCP. That's actually what we were doing before. Now if you omit failover_policy, then apply the plan, and then check it again you won't have the diff. However, if you then go to the affected load balancer in GCP Console web UI and you click update without changing anything you'll see the inverse of the diff above. It would try to clear the failover_policy again. If you then apply the plan it doesn't really do anything. From that point on you're stuck with the permadiff. The only way to resolve it is to set failover to false on any backends that have it enabled, apply the changes, and then go back to the values before. That way the failover_policy diff is gone.

Important Factoids

References

@github-actions
Copy link

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 Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.