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

Allow passing node service_account when autopilot enabled #6733

Merged
merged 1 commit into from
Nov 12, 2022

Conversation

JeremyOT
Copy link
Member

@JeremyOT JeremyOT commented Oct 22, 2022

Removes the conflict between cluster_autoscaling and autopilot making it possible to supply a service_account:

cluster_autoscaling.auto_provisioning_defaults.service_account

This change also makes cluster_autoscaling.enabled optional to simplify passing args when autopilot is enabled.

As a result it is now possible to pass false when creating autopilot clusters but this will be caught by server side validaton.

fixes hashicorp/terraform-provider-google#9505

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

container: fixed a bug where `cluster_autoscaling.auto_provisioning_defaults.service_account` can not be set when `enable_autopilot = true` for `google_container_cluster`

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @shuyama1, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 14 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 1 file changed, 14 insertions(+), 7 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2203
Passed tests 1963
Skipped tests: 239
Failed tests: 1

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]

All tests passed
View the build log or the debug log for each test

@modax
Copy link

modax commented Oct 22, 2022

@JeremyOT

  1. File changed - 2731 does not look right for this PR. You have included vendor/bundle/rubyin your PR, it does not look like it should be necessary.
  2. Have you tested if setting non-default oauth_scopes under cluster_autoscaling.auto_provisioning_defaults works for Autopilot?
  3. I believe you should tweak documentation regarding these Autopilot related settings. I believe an example in docs would be really helpful.
  4. Last but not least, a new integration test for both service_account and oauth_scopes would really help to avoid regressions (e.g. a test for example from documentation)

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 14 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 1 file changed, 14 insertions(+), 7 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2203
Passed tests 1964
Skipped tests: 239
Failed tests: 0

All tests passed in REPLAYING mode
View the build log

@JeremyOT
Copy link
Member Author

Accidentally caught the vendor dir with my amend alias - whoops.

Have you tested if setting non-default oauth_scopes under cluster_autoscaling.auto_provisioning_defaults works for Autopilot?

Yes, oauth_scopes may be passed though we recommend only using https://www.googleapis.com/auth/cloud-platform and controlling access with IAM instead.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 121 insertions(+), 39 deletions(-))
Terraform Beta: Diff ( 3 files changed, 123 insertions(+), 40 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2208
Passed tests 1967
Skipped tests: 239
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccContainerClusterCustomServiceAccount_withAutopilot|TestAccContainerCluster_nodeAutoprovisioning

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode:
TestAccContainerClusterCustomServiceAccount_withAutopilot[Error message] [Debug log]
TestAccContainerCluster_nodeAutoprovisioning[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 121 insertions(+), 39 deletions(-))
Terraform Beta: Diff ( 3 files changed, 129 insertions(+), 45 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2208
Passed tests 1966
Skipped tests: 239
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccContainerClusterCustomServiceAccount_withAutopilot|TestAccContainerCluster_nodeAutoprovisioning|TestAccComputeForwardingRule_update

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccContainerClusterCustomServiceAccount_withAutopilot[Debug log]
TestAccComputeForwardingRule_update[Debug log]

Tests failed during RECORDING mode:
TestAccContainerCluster_nodeAutoprovisioning[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 127 insertions(+), 39 deletions(-))
Terraform Beta: Diff ( 3 files changed, 135 insertions(+), 45 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2208
Passed tests 1966
Skipped tests: 239
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccContainerCluster_nodeAutoprovisioning|TestAccContainerClusterCustomServiceAccount_withAutopilot

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]
TestAccContainerClusterCustomServiceAccount_withAutopilot[Debug log]

Tests failed during RECORDING mode:
TestAccContainerCluster_nodeAutoprovisioning[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 124 insertions(+), 39 deletions(-))
Terraform Beta: Diff ( 3 files changed, 132 insertions(+), 45 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2208
Passed tests 1966
Skipped tests: 239
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccContainerCluster_nodeAutoprovisioning|TestAccContainerClusterCustomServiceAccount_withAutopilot

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]
TestAccContainerClusterCustomServiceAccount_withAutopilot[Debug log]

Tests failed during RECORDING mode:
TestAccContainerCluster_nodeAutoprovisioning[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2211
Passed tests 1971
Skipped tests: 239
Failed tests: 1

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccContainerCluster_nodeAutoprovisioning

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode:
TestAccContainerCluster_nodeAutoprovisioning[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 122 insertions(+), 38 deletions(-))
Terraform Beta: Diff ( 3 files changed, 130 insertions(+), 44 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2211
Passed tests 1970
Skipped tests: 239
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccContainerClusterCustomServiceAccount_withAutopilot

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]

Tests failed during RECORDING mode:
TestAccContainerClusterCustomServiceAccount_withAutopilot[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 122 insertions(+), 38 deletions(-))
Terraform Beta: Diff ( 3 files changed, 130 insertions(+), 44 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2211
Passed tests 1971
Skipped tests: 239
Failed tests: 1

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]

All tests passed
View the build log or the debug log for each test

@JeremyOT JeremyOT marked this pull request as ready for review October 30, 2022 17:32
@JeremyOT
Copy link
Member Author

@shuyama1 it looks like this one is good to go

Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
Type: schema.TypeBool,
Copy link
Member

Choose a reason for hiding this comment

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

I understand that making this optional will simplify user experience, but allowing empty block cluster_autoscaling{ } to be specified usually causes more problem in Terraform. Therefore I would recommend that we keep this field as required.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to make that change, but we're seeing a lot of friction with terraform's client side validation. It keeps causing unnecessary delays in support for new features. Especially when those features are ~support for existing fields (like this one).

Comment on lines +3734 to +3799
enableAutopilot := false
if v, ok := d.GetOk("enable_autopilot"); ok && v == true {
enableAutopilot = true
}
if !ok || l == nil || len(l) == 0 || l[0] == nil {
if v, ok := d.GetOk("enable_autopilot"); ok && v == true {
if enableAutopilot {
Copy link
Member

Choose a reason for hiding this comment

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

I am trying to understand the change here. Does this new change cover any cases that the previous code does not cover?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a logical change, however it makes additional autopilot conditionals simpler in the future

@@ -78,6 +78,13 @@ var (
forceNewClusterNodeConfigFields = []string{
"workload_metadata_config",
}

suppressDiffForAutopilot = schema.SchemaDiffSuppressFunc(func(k, oldValue, newValue string, d *schema.ResourceData) bool {
Copy link
Member

@shuyama1 shuyama1 Nov 9, 2022

Choose a reason for hiding this comment

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

Just want to confirm if my understanding is correct. This DSF is added to prevent premadiff for some fields that return computed values when enable_autopilot == true. If so, do you think making the field optional + computed will solve the problem? Plus, I've seen some fields have default values. Does the API return different values. If they are fixed default values, having them set from the Terraform side should not cause any permadiffs.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that these fields have default values, which conflicts with optional/computed. We can't remove the default values, but they will be ignored for Autopilot and the result is a permadiff

Copy link
Member

Choose a reason for hiding this comment

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

Ah, like for autopilot, the API will not return those values?

Copy link
Member Author

Choose a reason for hiding this comment

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

It returns different values, or no values for different fields. The intent here is essentially the field is optional + computed only when enable_autopilot == true

Copy link
Member

@shuyama1 shuyama1 Nov 10, 2022

Choose a reason for hiding this comment

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

Got it! Thanks! Then it sounds like that optional + computed make more sense for such fields than having default values on Terraform side.
For cases other than enable_autopilot == true, do these fields have the same server side defaults (plus the API also return these values) as the Terraform side ones. If so, I guess it would be relatively safe to change default values to optional + computed.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have the same defaults when Autopilot is enabled, and these may change over time as these values are implementation details for Autopilot, whereas they matter directly in GKE Standard.

This is another side effect of the dual purpose cluster APIs, but when Autopilot is enabled we cannot make any assumptions about server side values as their future changes are not considered breaking

Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline - The fields are required when Autopilot is not enabled. So changing to optional + computed will not work. DSF may be the best way to handle perma-diffs in this case.

Removes the conflict between cluster_autoscaling and autopilot making it
possible to supply a service_account:

`cluster_autoscaling.auto_provisioning_defaults.service_account`

This change also makes `cluster_autoscaling.enabled` optional to simplify
passing args when autopilot is enabled.

As a result it is now possible to pass false when creating autopilot
clusters but this will be caught by server side validaton.

fixes hashicorp/terraform-provider-google#9505
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 122 insertions(+), 38 deletions(-))
Terraform Beta: Diff ( 3 files changed, 130 insertions(+), 44 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2244
Passed tests 2001
Skipped tests: 241
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccContainerClusterCustomServiceAccount_withAutopilot|TestAccComputeForwardingRule_update

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccContainerClusterCustomServiceAccount_withAutopilot[Debug log]
TestAccComputeForwardingRule_update[Debug log]

All tests passed
View the build log or the debug log for each test

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants