-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add cross-region replication support to AlloyDB #9012
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
Merged
rileykarson
merged 46 commits into
GoogleCloudPlatform:main
from
199201shubhamsahu:alloydb-crr-support
Oct 10, 2023
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
d787493
Add fields for secondary cluster and create basic example
199201shubhamsahu 9c8ea97
Add custom pre create code to support creation of secondary cluster
199201shubhamsahu ba25c9d
Add basic tests and validation tests for secondary cluster
199201shubhamsahu 0012c50
Add forceful deletion for secondary cluster
199201shubhamsahu f26c8b6
Specify clusterType=PRIMARY in examples as clusterType is a new requi…
199201shubhamsahu d28e93d
Add implementation for promotion of secondary cluster
199201shubhamsahu 101cc52
Add cluster_type for tests
199201shubhamsahu 09354d6
Add required field cluster_type for remaining tests
199201shubhamsahu aee6a5e
Fix tests for secondary cluster
199201shubhamsahu 7dd152c
Comment out tests failing due to service networking issue
199201shubhamsahu fcefb0e
Fix cluster_type for secondary cluster test
199201shubhamsahu 3b87a2f
Remove required:true for clusterType and set PRIMARY as default
199201shubhamsahu 2b2df2b
Merge branch 'main' into alloydb-crr-support
199201shubhamsahu 2d37627
Add validation and tests for basic user journeys
199201shubhamsahu 613cc03
Update timeouts to 30 mins, reason: multiple failing tests
199201shubhamsahu 5966f2f
Add field for secondary instance and create basic example
199201shubhamsahu dbb8330
Add custom pre create/update/delete code to support implementation of…
199201shubhamsahu 4465e8b
Add tests for secondary instance
199201shubhamsahu 6316c8c
Add test for secondary cluster promotion
199201shubhamsahu 017d7fb
Remove legacy fmt.Printf() for warning message
199201shubhamsahu 9c42b06
Enable generated test for secondary instance
199201shubhamsahu 25fa414
Correct description for READ_POOL instance_type
199201shubhamsahu fb7688a
Merge branch 'main' into alloydb-crr-support
199201shubhamsahu 7a7e453
Fix changes in merge resolve
199201shubhamsahu f809fa3
Minor: Remove spacing and unncessary comments
199201shubhamsahu d715a0f
Remove explicit dependency on secondary cluster from description as i…
199201shubhamsahu 33b17f6
Remove cluster_type=PRIMARY as it is already the default value
199201shubhamsahu 4fe8f4c
Set secondary_config.primary_cluster_names as required
199201shubhamsahu dbf1fdd
Remove dead code
199201shubhamsahu 48af6b1
Fix secondary cluster basic example
199201shubhamsahu d733675
Fix secondary instance basic example
199201shubhamsahu 0847d2b
Remove inital user from secondary cluster example
199201shubhamsahu 118019b
Fix and add tests for secondary cluster
199201shubhamsahu afdeb16
Add deletion policy to forcefully delete the secondary cluster and th…
199201shubhamsahu e8e2270
Add deletion_policy to secondary instance basic example and remove in…
199201shubhamsahu 311fff5
Fix basic tests for secondary instance
199201shubhamsahu 43c42af
Remove changes for secondary instance and promotion, for PR to only h…
199201shubhamsahu 276a343
Add deletion_policy = FORCE for secondary clusters
199201shubhamsahu 66a0a68
Revert "Add deletion_policy = FORCE for secondary clusters"
199201shubhamsahu 5278034
Remove deletion_policy, will be adding implementation and tests in se…
199201shubhamsahu 14f82bc
Merge branch 'GoogleCloudPlatform:main' into alloydb-crr-support
199201shubhamsahu e6da0eb
Remove client_connection_config as it got rolled back
199201shubhamsahu 70dcd5e
Add ImportStateVerifyIgnore to secondary cluster tests
199201shubhamsahu ef48b6b
Set cluster_type as immutable and remove cluster_type update validation
199201shubhamsahu 89889d2
Remove cluster_type = PRIMARY as it is default value
199201shubhamsahu 559ce22
Set secondaryConfig.primaryClusterName as immutable
199201shubhamsahu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,9 +29,9 @@ async: !ruby/object:Api::OpAsync | |||||
| base_url: '{{op_id}}' | ||||||
| wait_ms: 1000 | ||||||
| timeouts: !ruby/object:Api::Timeouts | ||||||
| insert_minutes: 10 | ||||||
| update_minutes: 10 | ||||||
| delete_minutes: 10 | ||||||
| insert_minutes: 30 | ||||||
| update_minutes: 30 | ||||||
| delete_minutes: 30 | ||||||
| result: !ruby/object:Api::OpAsync::Result | ||||||
| path: 'response' | ||||||
| status: !ruby/object:Api::OpAsync::Status | ||||||
|
|
@@ -78,8 +78,15 @@ examples: | |||||
| ignore_read_extra: | ||||||
| - 'reconciling' | ||||||
| - 'update_time' | ||||||
| - !ruby/object:Provider::Terraform::Examples | ||||||
| name: 'alloydb_secondary_cluster_basic' | ||||||
| primary_resource_id: 'secondary' | ||||||
| vars: | ||||||
| alloydb_primary_cluster_name: 'alloydb-primary-cluster' | ||||||
| alloydb_primary_instance_name: 'alloydb-primary-instance' | ||||||
| alloydb_secondary_cluster_name: 'alloydb-secondary-cluster' | ||||||
| custom_code: !ruby/object:Provider::Terraform::CustomCode | ||||||
| pre_create: templates/terraform/pre_create/alloydb_restore_cluster.go.erb | ||||||
| pre_create: templates/terraform/pre_create/alloydb_cluster.go.erb | ||||||
| parameters: | ||||||
| - !ruby/object:Api::Type::String | ||||||
| name: 'clusterId' | ||||||
|
|
@@ -452,3 +459,24 @@ properties: | |||||
| - !ruby/object:Api::Type::String | ||||||
| name: 'sourceType' | ||||||
| description: 'Type of migration source.' | ||||||
| - !ruby/object:Api::Type::Enum | ||||||
| name: clusterType | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| values: | ||||||
| - :PRIMARY | ||||||
| - :SECONDARY | ||||||
| default_value: :PRIMARY | ||||||
|
199201shubhamsahu marked this conversation as resolved.
|
||||||
| immutable: true | ||||||
| description: | | ||||||
| The type of cluster. If not set, defaults to PRIMARY. | ||||||
| - !ruby/object:Api::Type::NestedObject | ||||||
| name: "secondaryConfig" | ||||||
|
199201shubhamsahu marked this conversation as resolved.
|
||||||
| description: | | ||||||
| Configuration of the secondary cluster for Cross Region Replication. This should be set if and only if the cluster is of type SECONDARY. | ||||||
| properties: | ||||||
| - !ruby/object:Api::Type::String | ||||||
| name: "primaryClusterName" | ||||||
|
199201shubhamsahu marked this conversation as resolved.
|
||||||
| immutable: true | ||||||
| required: true | ||||||
|
199201shubhamsahu marked this conversation as resolved.
|
||||||
| description: | | ||||||
| Name of the primary cluster must be in the format | ||||||
| 'projects/{project}/locations/{location}/clusters/{cluster_id}' | ||||||
54 changes: 54 additions & 0 deletions
54
mmv1/templates/terraform/examples/alloydb_secondary_cluster_basic.tf.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| resource "google_alloydb_cluster" "primary" { | ||
| cluster_id = "<%= ctx[:vars]['alloydb_primary_cluster_name'] %>" | ||
| location = "us-central1" | ||
| network = google_compute_network.default.id | ||
| } | ||
|
|
||
| resource "google_alloydb_instance" "primary" { | ||
| cluster = google_alloydb_cluster.primary.name | ||
| instance_id = "<%= ctx[:vars]['alloydb_primary_instance_name'] %>" | ||
| instance_type = "PRIMARY" | ||
|
|
||
| machine_config { | ||
| cpu_count = 2 | ||
| } | ||
|
|
||
| depends_on = [google_service_networking_connection.vpc_connection] | ||
| } | ||
|
|
||
| resource "google_alloydb_cluster" "<%= ctx[:primary_resource_id] %>" { | ||
| cluster_id = "<%= ctx[:vars]['alloydb_secondary_cluster_name'] %>" | ||
| location = "us-east1" | ||
| network = google_compute_network.default.id | ||
| cluster_type = "SECONDARY" | ||
|
|
||
| continuous_backup_config { | ||
| enabled = false | ||
| } | ||
|
|
||
| secondary_config { | ||
| primary_cluster_name = google_alloydb_cluster.primary.name | ||
| } | ||
|
|
||
| depends_on = [google_alloydb_instance.primary] | ||
| } | ||
|
|
||
| data "google_project" "project" {} | ||
|
|
||
| resource "google_compute_network" "default" { | ||
| name = "<%= ctx[:vars]['alloydb_secondary_cluster_name'] %>" | ||
| } | ||
|
|
||
| resource "google_compute_global_address" "private_ip_alloc" { | ||
| name = "<%= ctx[:vars]['alloydb_secondary_cluster_name'] %>" | ||
| address_type = "INTERNAL" | ||
| purpose = "VPC_PEERING" | ||
| prefix_length = 16 | ||
| network = google_compute_network.default.id | ||
| } | ||
|
|
||
| resource "google_service_networking_connection" "vpc_connection" { | ||
| network = google_compute_network.default.id | ||
| service = "servicenetworking.googleapis.com" | ||
| reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.