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 Bigtable autoscaling configs to Instance #5803

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

kongweihan
Copy link
Contributor

@kongweihan kongweihan commented Mar 9, 2022

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)

bigtable: added support for `autoscaling_config` to `google_bigtable_instance`

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

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

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@megan07, please review this PR or find an appropriate assignee.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@kongweihan kongweihan marked this pull request as ready for review March 10, 2022 17:17
@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@kongweihan kongweihan force-pushed the kongwh-autoscaling branch 3 times, most recently from e548dcd to 62d3aa9 Compare March 21, 2022 20:00
@megan07
Copy link
Contributor

megan07 commented Mar 21, 2022

/gcbrun

@megan07
Copy link
Contributor

megan07 commented Mar 21, 2022

Hi @kongweihan would you mind running go mod tidy to update the go.sum file please? Thanks!

@kongweihan
Copy link
Contributor Author

@megan07 I see the changelog-checker passes now, is that ok or do I still need to update go.sum? I'm not very familiar with go as it says go: go.mod file not found in current directory or any parent directory;. I need to init the mod locally?

@megan07
Copy link
Contributor

megan07 commented Mar 22, 2022

Hi @kongweihan, sorry, we just started managing this in magic-modules, so I was confused. You'll want to go to our downstream, make the update to go.mod there, then copy the go.sum file over here. Let me know if you have more questions! Thanks!

@megan07
Copy link
Contributor

megan07 commented Mar 22, 2022

/gcbrun

@kongweihan
Copy link
Contributor Author

@megan07 updated. I see that downstream repo has both bigtable 1.10.1 and 1.13 in go.sum. So I copied the lines over. Is that correct?

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

1 similar comment
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

Copy link
Contributor

@megan07 megan07 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, I needed to build and run locally. Tests passed, but there are some formatting issues. If you wouldn't mind fixing those up, I can get this merged today. Thanks so much!

Comment on lines 96 to 98
Type: schema.TypeInt,
Required: true,
Description: `The minimum number of nodes for autoscaling.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind formatting these, please? When I ran it locally I saw changes to these 3 attributes.

Suggested change
Type: schema.TypeInt,
Required: true,
Description: `The minimum number of nodes for autoscaling.`,
Type: schema.TypeInt,
Required: true,
Description: `The minimum number of nodes for autoscaling.`,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Will fix. And, looking at https://github.com/GoogleCloudPlatform/magic-modules/pull/5800/files
Should I also update the doc? This change will be directly available to customer right, so we should publish the doc change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, yes please! Sorry, I missed that. Thank you!

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 updated these, PTAL. Thanks!

// Create Autoscaling config with 2 nodes.
Config: testAccBigtableInstance_autoscalingCluster(instanceName, 2, 5, 70),
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr("google_bigtable_instance.instance",
"cluster.0.num_nodes", "2"),),
Copy link
Contributor

Choose a reason for hiding this comment

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

There was also some formatting on these lines of the tests as well. You can run make fmt in the downstream to find them all, that would be great.

Suggested change
"cluster.0.num_nodes", "2"),),
"cluster.0.num_nodes", "2")),

Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "A list of Autoscaling configurations. Only one element is used and allowed.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why a list is used here but exactly one element is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea it's the only way to nest a object into the schema in terraform. More details is in yaqs. See internal design doc.

"min_nodes": {
Type: schema.TypeInt,
Required: true,
Description: `The minimum number of nodes for autoscaling.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "The minimum number of nodes to scale down to"?

Similarly, "Maximum number of nodes to scale up to."

Required: true,
Description: `The maximum number of nodes for autoscaling.`,
},
"cpu_target": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing some minimum validation on these field? e.g. 0 < cpu_target <= 100?

At very minimum we should document this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It says that in the description?

Copy link
Contributor

Choose a reason for hiding this comment

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

})
}
autoscaling_configs := cluster["autoscaling_config"].([]interface{})
if len(autoscaling_configs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if len(autoscaling_configs) > 1? Are we silently dropping the rest of the configs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a check on the field validating it has at most 1 element.

// Create Autoscaling config with 2 nodes.
Config: testAccBigtableInstance_autoscalingCluster(instanceName, 2, 5, 70),
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr("google_bigtable_instance.instance",
"cluster.0.num_nodes", "2"),),
Copy link
Contributor

Choose a reason for hiding this comment

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

What are we checking here? only the allocated nodes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, since that might not be set in the config, I want to explicitly check it.

},
{
// Update Autoscaling configs.
Config: testAccBigtableInstance_autoscalingCluster(instanceName, 1, 5, 80),
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to verify the updates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default the test asserts on all the config fields.

ImportStateVerifyIgnore: []string{"deletion_protection", "instance_type"}, // we don't read instance type back
},
{
// Disable Autoscaling without specifying num_nodes, it should should use the current node count, which is 2.
Copy link
Contributor

Choose a reason for hiding this comment

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

"it should use the current node count"

@@ -230,6 +355,26 @@ resource "google_bigtable_instance" "instance" {
`, instanceName, instanceName, numNodes)
}


func testAccBigtableInstance_noNumNodes(instanceName string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting! I thought this is invalid. How can this work? Will users be confused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is invalid at create time but ok for update. We plan to keep this behavior in case people have config relying on this.

Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr("google_bigtable_instance.instance",
"cluster.0.num_nodes", "2"),),
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry! just curious. What does this step do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking that if we create a cluster with autoscaling.min_nodes = X, the cluster will start with X nodes.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 4 files changed, 213 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 4 files changed, 211 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 4 files changed, 211 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

@kongweihan kongweihan force-pushed the kongwh-autoscaling branch 2 times, most recently from 548eebf to 688727b Compare March 23, 2022 21:23
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 219 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 5 files changed, 219 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

1 similar comment
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 219 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 5 files changed, 219 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

@kongweihan kongweihan force-pushed the kongwh-autoscaling branch 2 times, most recently from 4a16aa7 to 7fe688d Compare March 23, 2022 21:39
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 216 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 5 files changed, 216 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

Design at go/cbt-autoscaler-terraform
Fixes hashicorp/terraform-provider-google#10758

```release-note:enhancement
bigtable: Added cluster autoscaling support
```
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 216 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 5 files changed, 216 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 14 insertions(+), 15 deletions(-))

@megan07
Copy link
Contributor

megan07 commented Mar 24, 2022

Looks good! Thank you for contributing!

@megan07 megan07 merged commit a2ab8e4 into GoogleCloudPlatform:main Mar 24, 2022
@kongweihan
Copy link
Contributor Author

kongweihan commented Mar 24, 2022

Thanks! How's the release process? When will this be available to customers? @megan07

@megan07
Copy link
Contributor

megan07 commented Mar 24, 2022

We have some maintenance being done next week on our release process, so this will likely be released the following week.

@kongweihan
Copy link
Contributor Author

How do I know when it's released?

@rileykarson
Copy link
Member

@kongweihan: I've linked internal material covering this in chat!

betsy-lichtenberg pushed a commit to betsy-lichtenberg/magic-modules that referenced this pull request Apr 25, 2022
Design at go/cbt-autoscaler-terraform
Fixes hashicorp/terraform-provider-google#10758

```release-note:enhancement
bigtable: Added cluster autoscaling support
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants