Skip to content

Add support for restoring AlloyDB clusters via backup restore and PITR#8575

Merged
shuyama1 merged 36 commits into
GoogleCloudPlatform:mainfrom
GoogleMarcfont:marcfont/restore
Aug 21, 2023
Merged

Add support for restoring AlloyDB clusters via backup restore and PITR#8575
shuyama1 merged 36 commits into
GoogleCloudPlatform:mainfrom
GoogleMarcfont:marcfont/restore

Conversation

@GoogleMarcfont

@GoogleMarcfont GoogleMarcfont commented Aug 7, 2023

Copy link
Copy Markdown
Member

Add support for restoring AlloyDB clusters via backup restore and PITR.

To restore a cluster directly from a backup, add the following line to your AlloyDB cluster:

restore_backup_source {
  backup_name = <fully qualified backup name>
}

To restore a cluster via PITR, add the following lines to your AlloyDB cluster:

restore_continuous_backup_source {
  cluster = <fully qualified source cluster name>
  point_in_time = <timestamp in RFC 3339 format>
}

Part of hashicorp/terraform-provider-google#13757. I am not fully closing the issue because I did not yet add support for data calls for backups as requested.

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).
  • 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).
  • Generated Terraform providers, and ran make test and make lint in the generated providers to ensure it passes unit and linter tests.
  • Ran relevant acceptance tests using my own Google Cloud project and credentials (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read Write release notes before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

alloydb: added `restore_backup_source` and `restore_continuous_backup_source` fields to support restore feature in `google_alloydb_cluster` resource.

@modular-magician

Copy link
Copy Markdown
Collaborator

Hello! I am a robot. It looks like you are a community contributor. @NickElliot, 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.

@GoogleMarcfont

Copy link
Copy Markdown
Member Author

Hi Nick, I added an example file I am not quite sure how to validate that everything is set up the example correctly. Do you know if there's a way to see the markdown output, i.e. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/alloydb_cluster?

@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 5 files changed, 1385 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1385 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 30 insertions(+))
TF OiCS: Diff ( 4 files changed, 165 insertions(+))

@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 897 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 4 files changed, 897 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 30 insertions(+))
TF OiCS: Diff ( 4 files changed, 165 insertions(+))

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 2936
Passed tests 2632
Skipped tests: 302
Affected tests: 2

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccAlloydbCluster_restore|TestAccAlloydbCluster_alloydbClusterRestoreExample

Get to know how VCR tests work

@modular-magician

Copy link
Copy Markdown
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccAlloydbCluster_restore[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

Comment thread mmv1/products/alloydb/Cluster.yaml Outdated
Comment on lines +214 to +247
- !ruby/object:Api::Type::String
name: 'restoreSourceBackup'
ignore_read: true
immutable: true
conflicts:
- restore_source_cluster
- restore_point_in_time
description: |
The name of the backup that this cluster should be restored from. Conflicts with 'restore_source_cluster' and 'restore_point_in_time', both can't be set together.
- !ruby/object:Api::Type::String
name: 'restoreSourceCluster'
ignore_read: true
immutable: true
required_with:
- restore_point_in_time
conflicts:
- restore_source_backup
description: |
The name of the source cluster that this cluster should be restored from. The source cluster must have continuous
backup enabled for restore to succeed. Requires `restore_point_in_time` to also be set.

Conflicts with 'restore_source_backup', both can't be set together.
- !ruby/object:Api::Type::String
name: 'restorePointInTime'
ignore_read: true
immutable: true
required_with:
- restore_source_cluster
conflicts:
- restore_source_backup
description: |
The point in time that this cluster should be restored to, in RFC 3339 format. Requires `restore_source_cluster` to also be set.

Conflicts with 'restore_source_backup', both can't be set together.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the explanation. I'd suggest that we keep the same structure as the API, as I feel that it may be slightly easier to read. Also it may be easier to keep in sync if more fields are added in the future.


if restoreBackup != nil || restoreSourceCluster != nil {
// Use restore API if this is a restore instead of a create cluster call
url = strings.Replace(url, "clusters?clusterId", "clusters:restore?clusterId", 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I was not clear earlier. By "users can also specify cluster settings via restore", I mean if users specify any fields in the cluster object, what will it happen if it conflicts with the source it restores from. I'm not super familiar with the resource, and it seems that you've already answered the question in your earlier response that "cluster has no overlap with the source field". Then I think it should be fine.

Comment thread mmv1/templates/terraform/pre_create/alloydb_restore_cluster.go.erb
@GoogleMarcfont

Copy link
Copy Markdown
Member Author

Replying to #8575 (comment) -

I understand your question now. The source cluster and destination cluster do not impact each other. Whatever is set in the destination cluster is what will be applied, and the restore doesn't care at all about the source cluster configuration. The restore will not copy any state from the source cluster.

@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field backup_source.backup_name changed from optional to required on google_alloydb_cluster - reference

If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a major release window. An override-breaking-change label can be added to allow merging.

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 882 insertions(+), 46 deletions(-))
Terraform Beta: Diff ( 4 files changed, 882 insertions(+), 46 deletions(-))
TF Conversion: Diff ( 1 file changed, 69 insertions(+))

1 similar comment
@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field backup_source.backup_name changed from optional to required on google_alloydb_cluster - reference

If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a major release window. An override-breaking-change label can be added to allow merging.

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 882 insertions(+), 46 deletions(-))
Terraform Beta: Diff ( 4 files changed, 882 insertions(+), 46 deletions(-))
TF Conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 2969
Passed tests 2666
Skipped tests: 302
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccAlloydbCluster_restore

Get to know how VCR tests work

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 2969
Passed tests 2664
Skipped tests: 302
Affected tests: 3

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccAlloydbCluster_restore|TestAccDataLossPreventionStoredInfoType_dlpStoredInfoTypeGroupIndexUpdate|TestAccDataLossPreventionJobTrigger_dlpJobTriggerInspectCustomInfoTypes

Get to know how VCR tests work

@modular-magician

Copy link
Copy Markdown
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccAlloydbCluster_restore[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@modular-magician

Copy link
Copy Markdown
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataLossPreventionStoredInfoType_dlpStoredInfoTypeGroupIndexUpdate[Debug log]
TestAccDataLossPreventionJobTrigger_dlpJobTriggerInspectCustomInfoTypes[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccAlloydbCluster_restore[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 882 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 4 files changed, 882 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 2969
Passed tests 2666
Skipped tests: 302
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccAlloydbCluster_restore

Get to know how VCR tests work

@modular-magician

Copy link
Copy Markdown
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccAlloydbCluster_restore[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 4 files changed, 882 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 4 files changed, 882 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician

Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 2980
Passed tests 2682
Skipped tests: 295
Affected tests: 3

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataplexDatascan_dataplexDatascanFullProfileExample|TestAccDataplexDatascan_dataplexDatascanBasicQualityExample|TestAccDataSourceGoogleServiceAccountIdToken_impersonation

Get to know how VCR tests work

@modular-magician

Copy link
Copy Markdown
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataplexDatascan_dataplexDatascanFullProfileExample[Debug log]
TestAccDataplexDatascan_dataplexDatascanBasicQualityExample[Debug log]
TestAccDataSourceGoogleServiceAccountIdToken_impersonation[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@shuyama1 shuyama1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding thorough tests!

@shuyama1
shuyama1 merged commit 6dfa322 into GoogleCloudPlatform:main Aug 21, 2023
nevzheng pushed a commit to nevzheng/magic-modules that referenced this pull request Aug 21, 2023
GoogleCloudPlatform#8575)

Co-authored-by: Nick Elliot <nickelliot@google.com>
Co-authored-by: Shuya Ma <87669292+shuyama1@users.noreply.github.com>
joelkattapuram pushed a commit to joelkattapuram/magic-modules that referenced this pull request Sep 20, 2023
GoogleCloudPlatform#8575)

Co-authored-by: Nick Elliot <nickelliot@google.com>
Co-authored-by: Shuya Ma <87669292+shuyama1@users.noreply.github.com>
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.

4 participants