feat: implementation of spanner instance_type to be able to provision a FREE_INSTANCE via terraform#13851
Conversation
|
Hello! I am a robot. Tests will require approval from a repository maintainer to run. Googlers: see go/terraform-auto-test-runs to set up automatic test runs. @slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 44 Click here to see the affected service packages
Action takenFound 7 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🟢 No issues found for passed tests after REPLAYING rerun. 🟢 All tests passed! |
|
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
| } | ||
|
|
||
| if count != 1 { | ||
| return nil, fmt.Errorf("Exactly one of `autoscaling_config`, `num_nodes`, or `processing_units` must be specified") |
There was a problem hiding this comment.
I don't think we want to throw this type of error here. exactly_one_of should present a plan-time error, but this is a runtime error.
We may need to remove the exactly_one_of, or replace it with at_least_one_of and include instance_type
There was a problem hiding this comment.
So the problem I ran into is that exactly_one_of that was already configured for num_nodes, processing_units and autoscaling_config. However, this now conflicts with instance_type == FREE_INSTANCE, e.g. with FREE_INSTANCE none of these fields are allowed to be configured, while with PROVISIONED instance exactly one of these fields should be configured. So my thought was to do a custom implementation in the encoder to solve this issue.
What would be your suggestion to solve this problem without causing a runtime error.
There was a problem hiding this comment.
I would probably move to at_least_one_of on all 4 of the fields. It won't be the most restrictive that we could be, but it will accomplish most of the goals at plan time. Most users will continue not setting instance_type, and instead have to specify one of the other fields
There was a problem hiding this comment.
I see, that makes sense. With the idea of it being an edge case, and the API will reject it with a descriptive message during the apply phase anyways for the users that still configure both?
There was a problem hiding this comment.
Just applied this, but thinking about it now this doesn't solve the problem (test TestAccSpannerInstance_freeInstanceBasicUpdate also fails now). Because at_least_one_of requires that either num_nodes, processing_units or autoscaling_config is set. For a FREE_INSTANCE none of these fields can be set which conflicts with "at least one of ...".
I guess the best way moving forward is only setting conflicts?
There was a problem hiding this comment.
I would add instance_type to the at_least_one_of. So a user can set instance_type = FREE instead of setting one of the other values.
Most people won't specify instance_type = PROVISIONED as examples won't specify, so the at_least_one_of will mostly work as intended
There was a problem hiding this comment.
Hmm I see, only weird scenario is then indeed when a user configures only instance_type=PROVISIONED (although not in any of the examples) on the api endpoint (during apply) you will probably still get an error even though the plan succeeds. But that is in this case the trade-off I guess.
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 45 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
d9c56f9 to
773c866
Compare
|
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
…a FREE_INSTANCE via terraform
Co-authored-by: Sam Levenick <slevenick@google.com>
5e8c7cb to
b0d9dcb
Compare
b0d9dcb to
7de012c
Compare
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 45 Click here to see the affected service packages
🟢 All tests passed! View the build log |
e4244f8
…on a `FREE_INSTANCE` via terraform (GoogleCloudPlatform#13851) Co-authored-by: Sam Levenick <slevenick@google.com>
…on a `FREE_INSTANCE` via terraform (GoogleCloudPlatform#13851) Co-authored-by: Sam Levenick <slevenick@google.com>
…on a `FREE_INSTANCE` via terraform (GoogleCloudPlatform#13851) Co-authored-by: Sam Levenick <slevenick@google.com>
…on a `FREE_INSTANCE` via terraform (GoogleCloudPlatform#13851) Co-authored-by: Sam Levenick <slevenick@google.com>


Solves hashicorp/terraform-provider-google#22596
feat: implementation of spanner
instance_typeto be able to provision aFREE_INSTANCEvia terraformexactly_one_ofbecause when provisioning a spanner instance with instance_type =FREE_INSTANCEneither one ofnum_nodesorprocessing_unitsorautoscaling_configis allowed to be configured.Added / direct affected tests pass locally:
Couldn't run all tests locally with
-run=TestAccSpannerInstance_because I ran into some org / quota policies on my sandbox project.Another thing to keep in mind, that makes testing a bit harder:
E.g.: tests always have to run on a "new" GCP project, not sure if that is solved within the CI?
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.