-
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 update support for bigtable clusters (such as resizing) #2350
Conversation
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. They will authorize it to run through our CI pipeline, which will generate downstream PRs. Thanks for your contribution! A human will be with you soon. @rileykarson, please review this PR or find an appropriate assignee. |
Will add test for this case. |
One challenge I have,
|
old_cluster_order = append(old_cluster_order, c) | ||
} | ||
} | ||
for _, value := range clusters { | ||
old_cluster_order = append(old_cluster_order, value) | ||
} | ||
|
||
err := diff.SetNew("cluster", old_cluster_order) |
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.
this is producing "Provider produced inconsistent final plan" after the change.
This feature is being tracked at a new issue, hashicorp/terraform-provider-google#4318. (Sorry for the web of BT cluster updating issues! I think I missed an xref between them somewhere.) I've been working with a member of the BT team to have this functionality added directly to the BT client library as https://code-review.googlesource.com/c/gocloud/+/44410, which should land soon. I'd strongly prefer we use that implementation instead of a separate one in TF. It's a commitment of mine to add it to the provider once that change lands. Given that, I'll probably take over the implementation unless you'd prefer to make the contribution. FWIW, the error you encountered is because Terraform |
@rileykarson I've spoken to Gary about that. If his change can land soon then great! |
@rileykarson , I've updated code and tests, so I don't have any more "inconsistent final plan". |
Sorry for the wait- I think https://code-review.googlesource.com/c/gocloud/+/44410 is close to merging. |
@@ -335,29 +364,43 @@ func resourceBigtableInstanceClusterReorderTypeList(diff *schema.ResourceDiff, m | |||
return fmt.Errorf("config is invalid: Too many cluster blocks: No more than 4 \"cluster\" blocks are allowed") | |||
} | |||
|
|||
if old_count.(int) != new_count.(int) { |
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.
The validation above here is worth preserving. I'd expect the new CustomizeDiff can supersede the rest, though.
@@ -236,16 +234,47 @@ func resourceBigtableInstanceUpdate(d *schema.ResourceData, meta interface{}) er | |||
clusterMap[cluster.Name] = cluster | |||
} | |||
|
|||
clusterTodoMap := make(map[string]interface{}, d.Get("cluster.#").(int)) |
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'd expect all this updating logic will go away, and get replaced by expanders very similar (if not identical) to Create; https://github.com/googleapis/google-cloud-go/blob/master/bigtable/admin.go#L1290 presents the same interface as it.
If they end up identical, feel free to refactor into a shared "expandBigtableInstance" method or just copy/paste. Either is fine.
new_clusters := make(map[string]interface{}, new_count.(int)) | ||
old_clusters := make(map[string]interface{}, old_count.(int)) | ||
|
||
for i := 0; i < new_count.(int) || i < old_count.(int); i++ { |
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.
Do you mind commenting the blocks like this with what they're doing? While it's possible to figure out, customizeDiffs are pretty finicky and it's a big help to be able to read quickly what they're doing.
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccBigtableInstance_one_in_the_cluster(instanceName, 3), | ||
Check: resource.ComposeTestCheckFunc( |
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.
After rebasing, you'll probably need to change to use "import-style" checks. See https://github.com/GoogleCloudPlatform/magic-modules/pull/2409/files#diff-1296b3b7cf174ed6b01d0139e46bdd24L69-R76.
If you're seeing differences on cluster
in "ImportStateVerify" that you don't expect, flag them here and don't worry about fixing them before pushing.
Superseded with #2923 Thanks for taking the time to submit this! Sorry about the unfortunate timing between your work + the client lib work I'd been waiting to integrate, you did a great job with your changes. |
This PR is to address Issue #2521 for terraform-google-provider
What will be doable is scaling up and down number of clusters within instance without recreate.
If anything else is changed within cluster (change of disk, zone, name) it will be forced to recreate, so the behaviour mimics what is possible in UI.
fyi:
I've tested it with all kind of scenarios (resize, force recreate, both)
Any feedback highly appreciated so I can complete this PR.