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

Fixed repeating changes google_service_usage_consumer_quota_override when override_value is 0 #2985

Merged
merged 2 commits into from
Mar 4, 2021

Conversation

korolvvn
Copy link
Contributor

@korolvvn korolvvn commented Feb 24, 2021

Resource google_service_usage_consumer_quota_override created with override_value = 0 is repeating changes.

  # google_service_usage_consumer_quota_override.consumer_quota["nvidia_a100_gpus"] will be updated in-place
  ~ resource "google_service_usage_consumer_quota_override" "consumer_quota" {
        dimensions     = {}
        force          = true
        id             = "projects/admin-team-dev-01/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fnvidia_a100_gpus/limits/%2Fproject%2Fregion/consumerOverrides/Cg1RdW90YU92ZXJyaWRl"
        limit          = "%2Fproject%2Fregion"
        metric         = "compute.googleapis.com%2Fnvidia_a100_gpus"
        name           = "Cg1RdW90YU92ZXJyaWRl"
      + override_value = "0"
        project        = "admin-team-dev-01"
        service        = "compute.googleapis.com"
    }

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

This is due to strange behavior of Google Cloud Platform API.
If a resource is created with "overrideValue": "0", then overrideValue is not stored in the API object at all.

$ gcurl "https://serviceusage.googleapis.com/v1beta1/${REGIONAL_LIMIT_RESOURCE_NAME}/consumerOverrides"
{
  "overrides": [
    {
      "name": "projects/428822275229/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fnvidia_a100_gpus/limits/%2Fproject%2Fregion/consumerOverrides/Cg1RdW90YU92ZXJyaWRlGhIKBnJlZ2lvbhIIdXMtZWFzdDQ=",
      "dimensions": {
        "region": "us-east4"
      }
    }
  ]
}

If overrideValue not equals 0, then is stored in object.

{
  "overrides": [
    {
      "name": "projects/428822275229/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fnvidia_a100_gpus/limits/%2Fproject%2Fregion/consumerOverrides/Cg1RdW90YU92ZXJyaWRlGhIKBnJlZ2lvbhIIdXMtZWFzdDQ=",
      "overrideValue": "1",
      "dimensions": {
        "region": "us-east4"
      }
    }
  ]
}
serviceusage: fixed an issue in `google_service_usage_consumer_quota_override` where setting the `override_value` to 0 would result in a permanent diff

@ghost ghost added size/xs labels Feb 24, 2021
@ghost ghost requested a review from c2thorn February 24, 2021 14:13
c2thorn added a commit to c2thorn/magic-modules that referenced this pull request Mar 1, 2021
`default_if_empty` custom flattener will not work here since `override_value` is required and has no default value
Our upstream automation will handle this
@c2thorn c2thorn merged commit 3ca3e5d into hashicorp:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants