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

add auto_provisioning_defaults to google_container_cluster.cluster_autoscaling #2747

Conversation

megan07
Copy link
Contributor

@megan07 megan07 commented Nov 25, 2019

Fixes hashicorp/terraform-provider-google#4061

Release Note Template for Downstream PRs (will be copied)

`container`: added `auto_provisioning_defaults` to `google_container_cluster.cluster_autoscaling`

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, a702925.

Pull request statuses

No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#1434
depends: GoogleCloudPlatform/terraform-google-conversion#268
depends: hashicorp/terraform-provider-google#4991


defaultScopes := []string{
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
Copy link
Member

Choose a reason for hiding this comment

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

Was it your experience that monitoring was a default sometimes, and other times it was monitoring.write? Did the default change based on logging_service and monitoring_service values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, yes, it did change. When monitoring_service was none the default was monitoring.write and when it is not none the default is monitoring.

Copy link
Member

Choose a reason for hiding this comment

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

Talked in Slack- let's only suppress monitoring.write. While monitoring and logging.write are conditionally enabled based on GKE Stackdriver Monitoring being enabled, I think it's a valid behaviour for Terraform to show a diff in that case- the user's config isn't the real state.

@@ -2840,6 +2879,35 @@ func cidrOrSizeDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return strings.HasPrefix(new, "/") && strings.HasSuffix(old, new)
}

// We want to suppress diffs for the default auto provisioning defaults
Copy link
Member

Choose a reason for hiding this comment

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

"Defaults" is somewhat overloaded, since https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#identity actually refers to a different set of scopes as defaults. Can we refer to this as suppressing scopes that are automatically added by GKE?

Additionally, I wonder if we can apply the same DSF to node_config fields because I believe they have the same behaviour.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 938bb29.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@megan07 megan07 requested a review from rileykarson November 26, 2019 19:04
@@ -2840,6 +2879,34 @@ func cidrOrSizeDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return strings.HasPrefix(new, "/") && strings.HasSuffix(old, new)
}

// We want to suppress diffs for the scopes automatically added by GKE
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// We want to suppress diffs for the scopes automatically added by GKE
// Suppress unremovable default scope values from GCP.
// If the default service account would not otherwise have it, the `monitoring.write` scope
// is added to a GKE cluster's scopes regardless of what the user provided.
// monitoring.write is inherited from monitoring (rw) and cloud-platform, so it won't always
// be present.
// Enabling Stackdriver features through logging_service and monitoring_service may enable
// monitoring or logging.write. We've chosen not to suppress in those cases because they're
// removable by disabling those features.

@@ -2642,6 +2644,12 @@ resource "google_container_cluster" "with_autoprovisioning" {
resource_type = "memory"
maximum = 2048
}
auto_provisioning_defaults {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if I include cluster_autoscaling without auto_provisioning_defaults or auto_provisioning_defaults without oauth_scopes? Will I get a diff?

Copy link
Member

Choose a reason for hiding this comment

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

Also, can you include an _updated config including monitoring.write and check that there are no changes in plan? (I think that's one of the options we have for a test step)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am adding O+C to auto_provisioning_defaults which should get rid of the diff if auto_provisioning_defaults is not included in a cluster_autoscaling block.

@@ -372,6 +375,14 @@ for a list of types.

* `maximum` - (Optional) Maximum amount of the resource in the cluster.

The `auto_provisioning_defaults` block supports:

* `oauth_scopes` - (Optional) Scopes that are used by NAP when creating node pools.
Copy link
Member

Choose a reason for hiding this comment

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

Can you note that monitoring.write will always be enabled regardless of user input, and add an infobox ( with ->) to say that GKE may enable monitoring or logging.write based on logging_service and monitoring_service values?

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for thoroughly working through the idiosyncrasies here!

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 23a93c5.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 6552bdb.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

1 similar comment
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 6552bdb.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 14ce2c3.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician modular-magician force-pushed the megan_autoprovisiondefaults branch from 14ce2c3 to 96ee7fb Compare November 26, 2019 23:30
@modular-magician modular-magician merged commit 020073b into GoogleCloudPlatform:master Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot configure AutoprovisioningNodePoolDefaults for GKE node auto-provisioning
4 participants