-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 support for processing_units
to google_spanner_instance
#4993
Add support for processing_units
to google_spanner_instance
#4993
Conversation
Co-authored-by: upodroid <cy@borg.dev>
Oops! It looks like you're using an unknown release-note type in your changelog entries:
Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md. |
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. @c2thorn, please review this PR or find an appropriate assignee. |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 3 files changed, 110 insertions(+), 5 deletions(-)) |
- !ruby/object:Provider::Terraform::Examples | ||
name: "spanner_instance_processing_units" | ||
primary_resource_id: "example" | ||
# Randomness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the randomness here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. Copied the other block
mmv1/products/spanner/api.yaml
Outdated
default_value: 1 | ||
description: | | ||
The number of nodes allocated to this instance. At most one of either node_count or processing_units can be present in terraforn. | ||
exactly_one_of: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could conflicts
be applied here instead of exactly_one_of
? That way we keep them mutually exclusive but neither are required
mmv1/products/spanner/api.yaml
Outdated
description: | | ||
The number of nodes allocated to this instance. At most one of either node_count or processing_units can be present in terraforn. | ||
exactly_one_of: | ||
- num_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- num_names | |
- num_nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that and it doesn't work. Trying conflicts_with
Pushed a commit with correct field name
brb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmv1 is buggy.
I, [2021-07-23T22:17:44.793294 #95375] INFO -- : products/pubsub: Not specified, skipping generation
bundler: failed to load command: compiler (compiler)
RuntimeError: num_nodes does not exist
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/type.rb:218:in `block in check_conflicts'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/type.rb:217:in `each'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/type.rb:217:in `check_conflicts'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/type.rb:136:in `validate'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:121:in `check_property_value'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:75:in `block in check'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `each'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `each_with_index'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `check'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/resource.rb:173:in `validate'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:121:in `check_property_value'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:75:in `block in check'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `each'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `each_with_index'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/google/yaml_validator.rb:74:in `check'
/Users/maha4472/Desktop/Git/magic-modules/mmv1/api/product.rb:59:in `validate'
compiler:178:in `block in <top (required)>'
compiler:144:in `each'
compiler:144:in `<top (required)>'
Regardless a schema like this doesn't work
"num_nodes": {
Type: schema.TypeInt,
Optional: true,
Description: `The number of nodes allocated to this instance. At most one of either node_count or processing_units can be present in terraforn.`,
Default: 1,
ConflictsWith: []string{"processing_units"},
},
"processing_units": {
Type: schema.TypeInt,
Optional: true,
Description: `The number of processing units allocated to this instance. At most one of processing_units
or node_count can be present in terraform.`,
ConflictsWith: []string{"num_nodes"},
},
Causes this error:
021/07/23 23:20:40 [DEBUG] Retry Transport: starting RoundTrip retry loop
2021/07/23 23:20:40 [DEBUG] Retry Transport: request attempt 0
2021/07/23 23:20:40 [DEBUG] Google API Request Details:
---[ REQUEST ]---------------------------------------
POST /v1/projects/REDACTED/instances?alt=json HTTP/1.1
Host: spanner.googleapis.com
User-Agent: Terraform/0.14.11 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/acc
Content-Length: 231
Content-Type: application/json
Accept-Encoding: gzip
{
"instance": {
"config": "projects/REDACTED/instanceConfigs/regional-us-central1",
"displayName": "Test Spanner Instance",
"labels": {
"foo": "bar"
},
"nodeCount": 1,
"processingUnits": 200
},
"instanceId": "tfgen-spanid-20210723222040904"
}
-----------------------------------------------------
2021/07/23 23:20:41 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Fri, 23 Jul 2021 22:20:41 GMT
Server: ESF
Server-Timing: gfet4t7; dur=446
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0
{
"error": {
"code": 400,
"message": "Invalid CreateInstance request. At most one of node_count or processing_units may be specified.",
"status": "INVALID_ARGUMENT"
}
}
-----------------------------------------------------
2021/07/23 23:20:41 [DEBUG] Retry Transport: Stopping retries, last request failed with non-retryable error: googleapi: got HTTP response code 400 with body: HTTP/2.0 400 Bad Request
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Fri, 23 Jul 2021 22:20:41 GMT
Server: ESF
Server-Timing: gfet4t7; dur=446
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0
{
"error": {
"code": 400,
"message": "Invalid CreateInstance request. At most one of node_count or processing_units may be specified.",
"status": "INVALID_ARGUMENT"
}
}
2021/07/23 23:20:41 [DEBUG] Retry Transport: Returning after 1 attempts
2021/07/23 23:20:41 [WARN] Got error running Terraform: exit status 1
Error: Error creating Instance: googleapi: Error 400: Invalid CreateInstance request. At most one of node_count or processing_units may be specified.
on terraform_plugin_test.tf line 2, in resource "google_spanner_instance" "example":
2: resource "google_spanner_instance" "example" {
provider_test.go:268: Step 1/2 error: Error running apply: exit status 1
Error: Error creating Instance: googleapi: Error 400: Invalid CreateInstance request. At most one of node_count or processing_units may be specified.
on terraform_plugin_test.tf line 2, in resource "google_spanner_instance" "example":
2: resource "google_spanner_instance" "example" {
--- FAIL: TestAccSpannerInstance_spannerInstanceProcessingUnitsExample (18.62s)
FAIL
FAIL github.com/hashicorp/terraform-provider-google/google 21.535s
FAIL
Removing the default value works but it is a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you can't avoid ExactlyOneOf
2021/07/23 23:25:43 [DEBUG] Google API Request Details:
---[ REQUEST ]---------------------------------------
POST /v1/projects/REDSACTED/instances?alt=json HTTP/1.1
Host: spanner.googleapis.com
User-Agent: Terraform/0.14.11 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/acc
Content-Length: 195
Content-Type: application/json
Accept-Encoding: gzip
{
"instance": {
"config": "projects/REDACTED/instanceConfigs/regional-us-central1",
"displayName": "Test Spanner Instance",
"labels": {
"foo": "bar"
}
},
"instanceId": "tfgen-spanid-20210723222543515"
}
-----------------------------------------------------
2021/07/23 23:25:44 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Fri, 23 Jul 2021 22:25:44 GMT
Server: ESF
Server-Timing: gfet4t7; dur=406
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0
{
"error": {
"code": 400,
"message": "Invalid CreateInstance request.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "instance.node_count",
"description": "Node count must be a positive number."
}
]
}
]
}
}
-
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 3 files changed, 110 insertions(+), 5 deletions(-)) |
@@ -102,8 +102,19 @@ objects: | |||
required: true | |||
- !ruby/object:Api::Type::Integer | |||
name: 'nodeCount' | |||
description: 'The number of nodes allocated to this instance.' | |||
default_value: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by note: While removing a default is a safe change, that's only if the field is moved to Optional
+ Computed
. We may need to use a CustomizeDiff
to simulate a default of 1
when processing_units
is unset, as breaking a config like the following working would also be backwards-incompatible. (Changing API requirements make backwards compatibility difficult!)
resource "google_spanner_instance" "example" {
config = "regional-us-central1"
display_name = "Test Spanner Instance"
labels = {
"foo" = "bar"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about if:
- I write an encoder that sets num_nodes to 1 if processing_units is 0, mark num_nodes as O+C and remove the default.
- Open an issue to make both of the fields ExactlyOneOf in v4 and remove the encoder?
- File an issue to fix that bug in the ruby generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that should also work. We should make sure to test a config w/o an explicit node_count
if we don't already.
This is resolved and ready to go now. |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 146 insertions(+), 3 deletions(-)) |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 150 insertions(+), 5 deletions(-)) |
/gcbrun |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 150 insertions(+), 5 deletions(-)) |
I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccCloudbuildWorkerPool_basic|TestAccContainerNodePool_basic|TestAccContainerNodePool_basicWithClusterId|TestAccContainerNodePool_withNetworkConfig|TestAccContainerNodePool_nodeLocations|TestAccContainerNodePool_withNodeConfig|TestAccContainerNodePool_withWorkloadIdentityConfig|TestAccContainerNodePool_maxPodsPerNode|TestAccContainerNodePool_withLinuxNodeConfig|TestAccContainerNodePool_withSandboxConfig|TestAccContainerNodePool_withKubeletConfig|TestAccContainerNodePool_withUpgradeSettings|TestAccContainerNodePool_withInvalidUpgradeSettings|TestAccContainerNodePool_withGPU|TestAccContainerNodePool_withManagement|TestAccContainerNodePool_withNodeConfigScopeAlias|TestAccContainerNodePool_autoscaling|TestAccContainerNodePool_resize|TestAccContainerNodePool_version|TestAccContainerNodePool_regionalAutoscaling|TestAccContainerNodePool_regionalClusters|TestAccContainerNodePool_012_ConfigModeAttr|TestAccContainerNodePool_EmptyGuestAccelerator|TestAccContainerNodePool_shieldedInstanceConfig|TestAccContainerNodePool_ephemeralStorageConfig|TestAccDataLossPreventionDeidentifyTemplate_dlpDeidentifyTemplateBasicExample|TestAccSpannerInstance_noNodeCountSpecified You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=199467 |
Confirmed that the change doesn't create a new diff for an existing config. Tests pass as well |
…leCloudPlatform#4993) Co-authored-by: upodroid <cy@borg.dev> Co-authored-by: Cameron Thornton <camthornton@google.com>
Fixes: hashicorp/terraform-provider-google#9599
This will be a breaking change as the new field is mutually exclusive with
num_nodes
.If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)