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

Support Cloud SQL Address Range Picker for Clones and Read replicas #5664

Merged

Conversation

shuyama1
Copy link
Member

@shuyama1 shuyama1 commented Jan 28, 2022

Fixes hashicorp/terraform-provider-google#11000

Also removed the ForceNew for allocated_ip_range field for primary instance update, as currently allocated IP range can not be updated only within a VPC - the field can be updated in place if we also update the private network. Therefore, recreation functionality should be added to this field in a general case. We could add a CustomizeDiff to only add ForceNew if allocated_ip_range is changed within a VPC, but I am not sure if that's something we want to add, as the API may change to include the update feature anytime, plus the allocated ip range does not support updating after creation using UI and I also wonder if users would appreciate recreation for sql instances in general.

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

sql: added field `clone.allocated_ip_range` to support address range picker for clone for resource `google_sql_database_instance`
sql: added support for address range picker for read replicas for resource `google_sql_database_instance`

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 222 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 5 files changed, 222 insertions(+), 3 deletions(-))
TF Validator: Diff ( 7 files changed, 244 insertions(+), 14 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic|TestAccApigeeEnvironmentIamBindingGenerated|TestAccApigeeEnvironmentIamMemberGenerated|TestAccApigeeEnvironmentIamPolicyGenerated|TestAccCloudbuildWorkerPool_basic|TestAccComputeGlobalForwardingRule_externalCndLbWithBackendBucketExample|TestAccContainerCluster_withAddons|TestAccServiceNetworkingPeeredDNSDomain_basic|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange_replica|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange_clone You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=249753

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 223 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 223 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 245 insertions(+), 16 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccApigeeEnvironmentIamBindingGenerated|TestAccApigeeEnvironmentIamMemberGenerated|TestAccApigeeEnvironmentIamPolicyGenerated|TestAccCloudbuildWorkerPool_basic|TestAccComputeGlobalForwardingRule_externalCndLbWithBackendBucketExample|TestAccContainerCluster_withAddons|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeReplica|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeClone|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=250521

@shuyama1
Copy link
Member Author

shuyama1 commented Feb 1, 2022

/gcbrun

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 223 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 223 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 245 insertions(+), 16 deletions(-))

@@ -311,7 +311,6 @@ settings.backup_configuration.binary_log_enabled are both set to true.`,
"allocated_ip_range": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the update case for this field something we can add a test for, or is it too hard to orchestrate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create a test on updating this field with a new private network, as I mentioned in the PR description, but just not within the same VPC. I will add one on this.

func TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeClone(t *testing.T) {
t.Parallel()

databaseName := "tf-test-" + randString(t, 10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting here that we cannot use the bootstrap db instance since this uses a private network. If more than one private network clone/backup test is needed, we should create a new bootstrap instance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! Looks like this is the only one now. We will probably need to create a bootstrap instance with private networks if more tests need it.

resource "google_sql_database_instance" "instance" {
depends_on = [google_service_networking_connection.foobar]
name = "%s"
region = "europe-west4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this region is one of the limited regions available for this feature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct

@rileykarson
Copy link
Member

(also note: we should hold merging on confirmation of full rollout)

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic|TestAccApigeeEnvironmentIamBindingGenerated|TestAccApigeeEnvironmentIamMemberGenerated|TestAccApigeeEnvironmentIamPolicyGenerated|TestAccComputeBackendServiceIamBindingGenerated|TestAccComputeBackendServiceIamMemberGenerated|TestAccComputeBackendServiceIamPolicyGenerated|TestAccComputeBackendServiceIamBindingGenerated_withCondition|TestAccComputeBackendServiceIamMemberGenerated_withCondition|TestAccComputeBackendServiceIamPolicyGenerated_withCondition|TestAccCloudbuildWorkerPool_basic|TestAccComputeGlobalForwardingRule_externalCndLbWithBackendBucketExample|TestAccComputeSecurityPolicy_withRateLimitOptions|TestAccContainerCluster_withAddons|TestAccContainerCluster_nodeAutoprovisioning|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeReplica|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeClone|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=251051

@shuyama1 shuyama1 force-pushed the range_picker_clone_replica branch from 7d7f84e to 65d5376 Compare February 1, 2022 20:43
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 236 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 236 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 258 insertions(+), 16 deletions(-))

1 similar comment
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 236 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 236 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 258 insertions(+), 16 deletions(-))

@shuyama1 shuyama1 force-pushed the range_picker_clone_replica branch from 1b1786a to 363aa17 Compare February 2, 2022 01:36
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 233 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 233 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 256 insertions(+), 16 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 234 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 234 insertions(+), 5 deletions(-))
TF Validator: Diff ( 7 files changed, 256 insertions(+), 16 deletions(-))

@shuyama1
Copy link
Member Author

shuyama1 commented Feb 2, 2022

Created separate private networks for each test (primary, read replica and clone). Should be fine to run tests in parallel now. As the networks are created as bootstrap (basically two extra bootstrap Networks are added), it should not hit the quota issue.
Triggered these tests in an independent run, and tests passed https://ci-oss.hashicorp.engineering/buildConfiguration/GoogleCloudBeta_ProviderGoogleCloudBetaMmUpstream/251554?buildTab=tests&status=passed

@shuyama1 shuyama1 force-pushed the range_picker_clone_replica branch from 2696036 to 366d4cb Compare February 7, 2022 21:30
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 214 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 214 insertions(+), 5 deletions(-))
TF Validator: Diff ( 2 files changed, 11 insertions(+), 10 deletions(-))

@shuyama1 shuyama1 force-pushed the range_picker_clone_replica branch from 366d4cb to 2260e35 Compare February 8, 2022 19:53
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 214 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 5 files changed, 214 insertions(+), 5 deletions(-))
TF Validator: Diff ( 2 files changed, 11 insertions(+), 10 deletions(-))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TF support for Cloud SQL Address Range Picker for Clones and Read replicas
4 participants