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 Cross region replication option for AlloyDB #13251

Closed
imrannayer opened this issue Dec 15, 2022 · 13 comments
Closed

Add Cross region replication option for AlloyDB #13251

imrannayer opened this issue Dec 15, 2022 · 13 comments

Comments

@imrannayer
Copy link

imrannayer commented Dec 15, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

New or Affected Resource(s)

  • google_alloydb_cluster
  • google_alloydb_instance

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.

References

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Jul 20, 2023

If possible, I would like to pick this up asap! :) cc @trodge / @rileykarson

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Jul 20, 2023

I'm curious, I haven't seen such API behaviour before - to create a secondary AlloyDB cluster there seems to be a 'secondarycreate' API call.. https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.clusters/createsecondary

How would we go about implementing something like this, would this mean we need to create another AlloyDB resource, e.g. google_alloydb_cluster_secondary and google_alloydb_instance_secondary even though the spec is exactly the same as the normal create call, I reckon we can just straight-up copy it and there's some Google magic making it a 'secondary' I reckon ? @trodge / @rileykarson

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Jul 20, 2023

Update: it seems like we need to create a google_alloydb_cluster_secondary and google_alloydb_instance_secondary - we can easily do this by copying the 2 existing products (Cluster and Instance) and adding 1 field extra to 'ClusterSecondary' :)

The cluster type is determined by which RPC was used to create the cluster (i.e. clusters.create vs. clusters.createsecondary

image

@bschaatsbergen
Copy link
Member

I've prepped a PR which is ready for review, it introduces the 2 new resources:

  • google_alloydb_cluster_secondary
  • google_alloydb_instance_secondary

@rileykarson rileykarson assigned bschaatsbergen and unassigned trodge Jul 20, 2023
@rileykarson
Copy link
Collaborator

Hmm- we may want to change the create call in the current resource based on a flag than introduce entirely new resources. That limits the opportunity for drift between the resource schemas substantially, I'm not entirely sure which would be better. FYI @ScottSuarez as reviewer, we may want to work out with the service team how we want to support this.

@bschaatsbergen
Copy link
Member

For maintainability it would be preferred if the service team could simply add a flag to the create call to instruct whether under the hood createsecondary should be called or not @rileykarson / @ScottSuarez.

For the sake of supporting this the Terraform Google provider, I'm unsure how long such a request with the service team might take.

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Jul 24, 2023

Heya @rileykarson / @ScottSuarez, is there any update on how we could possibly approach this? Or perhaps refactor it later?

@ScottSuarez
Copy link
Collaborator

Given how there is no way to manage the secondary cluster independently and that it is always tied to the first I'd propose the following:

  1. Add a field create_secondary<bool> - default false with url_param_only or a virtual_field set.
  2. This field should be default: false and input:true
  3. Add a post_create method that will call the api to create the secondary instance based on this parameter.

This is assuming the following from the API team.

  1. Managing secondary clusters won't scale to be more nuanced.
  2. This management style makes sense from the teams point of view and lines up with your design philosophy. (secondary is heavily tied to main).

@bschaatsbergen
Copy link
Member

Right on, I'll get to this today @ScottSuarez

@KristoferNorwood
Copy link

I was able to create a secondary cluster using the AlloyDB Cluster Terraform resource, which is super nice. Thank you for all of your effort on that!

However, I noticed that the secondary instance was not created and I don't see a SECONDARY instance type attribute listed in the AlloyDB Instance Terraform resource. I was able to create the resource using the alloydb create-secondary gcloud command, thankfully.

I was wondering, there a plan to implement the Secondary instance type in the terraform resource?

@rileykarson
Copy link
Collaborator

GoogleCloudPlatform/magic-modules#9203 was merged 4 days ago, that should release next Monday assuming no surprises (along with promotion in GoogleCloudPlatform/magic-modules#9271, probably, and the week after if not). This just got released as piecemeal because we broke up the change into distinct parts.

@imrannayer
Copy link
Author

Part of provider 5.5 release

Copy link

github-actions bot commented Dec 9, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.