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

Persistent terraform plan Changes with google_compute_region_disk Labels Including goog-gke-volume #16528

Closed
inobu opened this issue Nov 14, 2023 · 9 comments

Comments

@inobu
Copy link

inobu commented Nov 14, 2023

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 version: 1.6.3
  • provider version: 5.6.0

Affected Resource(s)

  • google_compute_region_disk

Terraform Configuration Files

# Copy-paste your Terraform configurations here.
#
# For large Terraform configs, please use a service like Dropbox and share a link to the ZIP file.
# For security, you can also encrypt the files using our GPG public key:
#    https://www.hashicorp.com/security
#
# If reproducing the bug involves modifying the config file (e.g., apply a config,
# change a value, apply the config again, see the bug), then please include both:
# * the version of the config before the change, and
# * the version of the config after the change.
resource "google_compute_region_disk" "example" {
  # ... other configuration ...

  labels = {
    goog-gke-volume = ""
  }
}

Debug Output

Panic Output

Expected Behavior

The terraform apply should recognize the applied label configuration and not propose any changes on subsequent terraform plan executions when no changes are made to the labels.

Actual Behavior

Even after applying the configuration with the goog-gke-volume label, every execution of terraform plan suggests that there are changes to be made to the terraform_labels.

Steps to Reproduce

  1. Define a google_compute_region_disk resource with a goog-gke-volume label.
  2. Run terraform apply to apply the configuration.
  3. Run terraform plan again, and observe that it suggests changes to the terraform_labels, even though there were no changes to the labels.

Important Factoids

References

  • #0000

b/311366422

@inobu inobu added the bug label Nov 14, 2023
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-pd labels Nov 14, 2023
@edwardmedia edwardmedia self-assigned this Nov 14, 2023
@edwardmedia
Copy link
Contributor

I can repro it

  # google_compute_region_disk.primary will be updated in-place
  ~ resource "google_compute_region_disk" "primary" {
      ~ effective_labels          = {
          + "goog-gke-volume" = (known after apply)
        }
        id                        = "projects/myproject/regions/us-central1/disks/issue16528"
      ~ labels                    = {
          + "goog-gke-volume" = ""
        }
        name                      = "issue16528"
      ~ terraform_labels          = {
          + "goog-gke-volume" = (known after apply)
        }
        # (11 unchanged attributes hidden)
    }

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

@edwardmedia edwardmedia removed their assignment Nov 14, 2023
@edwardmedia edwardmedia removed the forward/review In review; remove label to forward label Nov 14, 2023
@trodge
Copy link
Collaborator

trodge commented Nov 16, 2023

@zli82016 would this be an example of an issue that will be fixed in the next release by your pull request?

@zli82016
Copy link
Collaborator

It is a separate issue. I will look into it.

@zli82016
Copy link
Collaborator

zli82016 commented Nov 20, 2023

This is a regression introduced in provider 5.x due to the labels rework and cannot be resolved. Please see more details in the provider 5.0 upgrade guide.

It is caused by the empty string label value. Can you please replace the label value with _ or true?

@steffencircle
Copy link

Hey,

as the label is originally set by the Platform, i am a bit worried that changing it's value has some sort of side-effect.
Therefore i am wondering if there is a better approach to this....

@zli82016
Copy link
Collaborator

Hey,

as the label is originally set by the Platform, i am a bit worried that changing it's value has some sort of side-effect. Therefore i am wondering if there is a better approach to this....

Do you know which platform the label is set by? Do you have more details?

The label is set in the configuration, and not returned as the system label by API.

@steffencircle
Copy link

Hi,

sorry by "platform" i meant Google Cloud itself, but more precisely the GKE Service.
goog-gke-volume is a label that gets automatically assigned to Disks that are used as Persistent Volumes.
Which is exactly what we do here. we create Regional Disks via Terraform and then use it as volumes in GKE.

You can read more about this here https://cloud.google.com/kubernetes-engine/docs/how-to/creating-managing-labels#automatically-applied-labels

Hope this clarifies

@zli82016
Copy link
Collaborator

Thanks for the information.

You can use ignore_changes to ignore the change of this label.

  lifecycle {                     
    ignore_changes = [
      terraform_labels["goog-gke-volume"],
    ]
  }

Sorry for the issue.

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 Jan 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants