hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.73k forks source link

google_tags_tag_value poor API performance #16584

Open duxbuse opened 10 months ago

duxbuse commented 10 months ago

Community Note

Terraform Version

❯ tf version Terraform v1.5.7 on darwin_arm64

Affected Resource(s)

google_tags_tag_value

Terraform Configuration Files

# key value for each role with the specific justification
resource "google_tags_tag_value" "project-values" {
  for_each        = { for k, v in var.methods : v.method => v.justification if var.target == "project" }
  parent            = tagKeys/google_tags_tag_key.project-key[0].name
  short_name  = each.key
  description.  = each.value
}

Debug Output

google_tags_tag_value.project-values["198"]: Destruction complete after 6m27s 

Expected Behavior

The first tag in the list that needs to be created or destroyed takes ~5 seconds. I expected this to remain constant for all ~400 changes.

Actual Behavior

When multiple tags need to be modified (created/destroyed) the time of each subsequent tag gets longer and longer and longer. Terraform by default seems to run about 10 at a time which can cause these tags to take easily over 6 minutes each.

This means that to update 400 tags, you have to destroy them then re-create them with the new values. 4002~6mins is like 80 hours to run the terraform which is crazy.

Steps to Reproduce

try to modify 100+ tags values in one terraform apply and see the performance seriously degrade.

  1. terraform apply

Important Factoids

It happens on both create and destroy actions. seems to overload the API server

References

b/312911278

zli82016 commented 10 months ago

Need to forward to service team.

SarahFrench commented 10 months ago

Hi @duxbuse could you please confirm if you're still experiencing this issue? We think there was a problem last week affecting tagging that should be resolved by now

duxbuse commented 10 months ago

Hi @SarahFrench it is better, most tags are now being created in ~2mins but that is still way longer than the first tag that only takes like 5 seconds.