-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: implementation of spanner instance_type
to be able to provision a FREE_INSTANCE
via terraform
#13851
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
base: main
Are you sure you want to change the base?
Conversation
…a FREE_INSTANCE via terraform
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
?
Co-authored-by: Sam Levenick <[email protected]>
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. |
55f8aec
to
59bdfb5
Compare
59bdfb5
to
d9c56f9
Compare
d9c56f9
to
773c866
Compare
Solves hashicorp/terraform-provider-google#22596
feat: implementation of spanner
instance_type
to be able to provision aFREE_INSTANCE
via terraformexactly_one_of
because when provisioning a spanner instance with instance_type =FREE_INSTANCE
neither one ofnum_nodes
orprocessing_units
orautoscaling_config
is 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.