Terraform-provider-google: Updating resource_labels field on google_container_cluster fails with a 400 error

Created on 7 Feb 2020  ·  9Comments  ·  Source: hashicorp/terraform-provider-google


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.12.20
+ provider.google v3.7.0

Affected Resource(s)

  • google_container_cluster

Terraform Configuration Files

resource "google_container_cluster" "default" {
  ...

  # First create a cluster without resource_labels set, then re-apply after setting a label 
  resource_labels = {
    key = "value"
  }
}

Debug Output

https://gist.github.com/chrisob/52250906dc38c6f300673033a60c26a1

Panic Output

Expected Behavior

TF should be able to update a GKE cluster's resource_labels on the fly.

Actual Behavior

Because the request body doesn't include the field labelFingerprint, TF gets a 400 error back from GCP complaining that:

Error: googleapi: Error 400: Labels could not be set due to fingerprint mismatch; try again with the proper fingerprint: incorrect fingerprint supplied was "", the expected one is "a9dc16a7"., failedPrecondition

Steps to Reproduce

  1. terraform apply to create a google_container_cluster without any resource_labels set.
  2. Add resource_labels to the google_container_cluster, and attempt another terraform apply

Important Factoids

Looking at the API spec for setResourceLabels, it's pretty clear that the issue is the missing labelFingerprint field in the request body.

References

Relevant GCP API call: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters/setResourceLabels

  • #0000
bug

Most helpful comment

v3.9.0 was cut before the change went in. The fix should be available in v3.10.0 which should be released around 2/24.
If needed sooner, you can always build directly from the master branch.

All 9 comments

@c2thorn I see the same problem. Debug.log is the same (above). In the plan I do see

      ~ resource_labels             = {
          + "key" = "value"
        }

The same issue affects terraform-provider-google-beta (v2.18.1 in my case).

Thanks for contributing @eadred! Merged in your changes. If you ever want to contribute in the future, the easiest way is to make a change in our Magic Modules repo like so: https://github.com/GoogleCloudPlatform/magic-modules/pull/3128. That way it will make the same change to both providers.

Either way, thanks a ton for helping out!

Hey guys,
Is this issue supposed to be fixed already?
I am stucked because of that atm. Any advices?

Terraform v0.12.20
+ provider.google v3.8.0
+ provider.google-beta v3.8.0

The fixes didn't make it into v3.8.0 - presumably the next release will have them.

v3.9.0 was cut before the change went in. The fix should be available in v3.10.0 which should be released around 2/24.
If needed sooner, you can always build directly from the master branch.

Any chance we can get a v2.20+ that includes this fix? It looks like both branches were patched, we just need a release if I'm reading correctly.

The fix only went into HEAD, but you should be able to fork and cherry pick the fix onto v2.20. It worked OK without any changes on v2.18.

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings