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

Added check for beta feature field istio_enabled #230

Merged
merged 2 commits into from
Sep 10, 2019

Conversation

richardmcsong
Copy link
Contributor

Some beta feature fields may not be returned by the Google API call that terraform uses.

According to Google Support (Case 20165122), when asked why certain Google API calls don't return istio_config or pod_security_policy_config:

Actually the fields are not optional. If you have those features enabled in your cluster it will show up in the description. These fields default to disabled and when they are disabled they are not present in the rest resource which is why these fields are missing in the cluster description. The API is configured to register them as disabled if left blank.

Since the terraform provider upstream operates by transpiling the API call into the correct resources, I thought it might be most appropriate to code defensively here and check for the field before trying to access it. Fixes #226

I also added resource_usage_export_config support in this PR (https://www.terraform.io/docs/providers/google/r/container_cluster.html#resource_usage_export_config).

Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! It looks pretty good, just needs a type change and to fix merge conflicts.

autogen/variables.tf Outdated Show resolved Hide resolved
@morgante
Copy link
Contributor

FYI we have consolidated the zonal and regional resources into a single resource so this PR will need to be rebased. Thanks!

@aaron-lane aaron-lane added the enhancement New feature or request label Aug 16, 2019
@richardmcsong
Copy link
Contributor Author

image

I'm sorry if this is a really stupid question, but why is this happening? it doesn't error out if i swap over to google_container_cluster.primary.addons_config.0.istio_config == [], but i thought when the expression evals to false that it goes to the second result after the colon, not to the first... Am I going nuts?

@paulpalamarchuk
Copy link
Contributor

image

I'm sorry if this is a really stupid question, but why is this happening? it doesn't error out if i swap over to google_container_cluster.primary.addons_config.0.istio_config == [], but i thought when the expression evals to false that it goes to the second result after the colon, not to the first... Am I going nuts?

@richardmcsong google_container_cluster.primary.addons_config.0.istio_config != [] not the same as google_container_cluster.primary.addons_config.0.istio_config != [{}] (empty list is not equal to list with one element that is empty object).

@paulpalamarchuk
Copy link
Contributor

@richardmcsong Define, please, version of provider google-beta "~> 2.10.0", to use resource_usage_export_config and remove older version mentions. Thank you

paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 19, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 19, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 20, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 20, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 20, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 20, 2019
…usage export config

 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 21, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
 * Fixed `google-beta` provider version
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 22, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 22, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
paulpalamarchuk added a commit to paulpalamarchuk/terraform-google-kubernetes-engine that referenced this pull request Aug 22, 2019
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
@richardmcsong
Copy link
Contributor Author

image
I'm sorry if this is a really stupid question, but why is this happening? it doesn't error out if i swap over to google_container_cluster.primary.addons_config.0.istio_config == [], but i thought when the expression evals to false that it goes to the second result after the colon, not to the first... Am I going nuts?

@richardmcsong google_container_cluster.primary.addons_config.0.istio_config != [] not the same as google_container_cluster.primary.addons_config.0.istio_config != [{}] (empty list is not equal to list with one element that is empty object).

But it says an EMPTY list of objects, not a list of empty objects. Also, I tried doing [{}]:
image

@morgante
Copy link
Contributor

#238 was merged to provide resource usage export config, but the beta feature checks are still helpful. Can you rebase?

@richardmcsong richardmcsong reopened this Sep 10, 2019
@richardmcsong
Copy link
Contributor Author

Finally got a chance to rebase. Noticed the other beta features were already done, just missing the istio one. Also fixed some naming, because it's actually detecting for the disabled flag, not the enabled flag.

@richardmcsong richardmcsong changed the title Added check for beta feature fields, as well as support for resource usage export config Added check for beta feature fields istio_enabled Sep 10, 2019
@richardmcsong richardmcsong changed the title Added check for beta feature fields istio_enabled Added check for beta feature field istio_enabled Sep 10, 2019
@morgante morgante merged commit 9f71320 into terraform-google-modules:master Sep 10, 2019
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
 * Based on PR terraform-google-modules#230
 * Add support for beta feature resource_usage_export_config (Fixes terraform-google-modules#232)
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
…ster

Added check for beta feature field istio_enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Certain fields may be missing from google's API call while refreshing state
4 participants