-
Notifications
You must be signed in to change notification settings - Fork 63
feat: adding the ability to enable cross-region automated backup replication #264
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
base: main
Are you sure you want to change the base?
feat: adding the ability to enable cross-region automated backup replication #264
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jtgorny The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @jtgorny. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
knottnt
left a comment
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.
Thanks for the contribution @jtgorny. Left a few comments.
Also it looks some generated files had changes that weren't created by our code-generator tool. You can find some documentation on how to setup that tool in our contributor docs.
| import boto3 | ||
| rds_client = boto3.client('rds') |
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 can use the rds_client pytest fixture
| # Wait for StartDBInstanceAutomatedBackupsReplication to complete | ||
| # This happens after ModifyDBInstance completes, so we need to wait for | ||
| # the replication status to be populated in the CR status field | ||
| import datetime |
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.
nit: this can be imported at the top of the file with the rest of the imports.
| # Wait for the resource to get synced after disabling replication | ||
| assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=MAX_WAIT_FOR_SYNCED_MINUTES) | ||
|
|
||
| # Verify the CR is synced and replication is disabled |
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 we need to check cr['status']['dbInstanceAutomatedBackupsReplications'] no longer has the cross-region destination?
| IOPS: | ||
| late_initialize: | ||
| skip_incomplete_check: {} | ||
| BackupCrossRegionReplication: |
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.
Q: Does RDS limit a DB instance to only a single cross-region backup or can there be multiple cross-region destinations?
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.
Single cross-region
| latestEnabled := latest.ko.Status.DBInstanceAutomatedBackupsReplications != nil && | ||
| len(latest.ko.Status.DBInstanceAutomatedBackupsReplications) > 0 |
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.
Is it safe to assume that any existing DBInstanceAutomatedBackupsReplications is the same as the one specified in desired's spec?
| return rm.onError(r, err) | ||
| } | ||
|
|
||
| // Handle cross-region backup replication on every reconcile, even when there's no spec delta. |
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 function is generated by our code-generator tool and isn't intended to have custom code added to it. Additionally, this function is only intended to retrieve the current state of the AWS resource. Making modifications to its state is very unexpected behavior for this function.
Normally, modifications to the state of the AWS resource are performed in sdkUpdate. Note, that function is also generated. We have a number of hooks that can be applied to the generated code to add custom logic for performing updates. You can find the hooks already being applied to DBInstance's sdkUpdate here. If you need to wait for the DBInstance to be in a particular state before applying modifications to cross-region backups returning a Requeue error from sdkUpdate should be sufficient.
| format: int64 | ||
| type: integer | ||
| backupCrossRegionReplication: | ||
| default: false |
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.
Our CRDs are also generated and usually we want to leave any defaults up to the AWS API instead of defining them within ACK.
| exit := rlog.Trace("rm.manageCrossRegionBackupReplication") | ||
| defer func(err error) { exit(err) }(err) | ||
|
|
||
| // Check if replication state changed |
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.
Generally, we want to do delta comparisons in delta.go. If custom comparison logic is needed you instruct the code-generator to omit generating comparison logic and add the custom logic to the delta_pre_compare hook.
Issue #, if available:
refs #2725
Description of changes:
Adding the ability to enable cross-region replication on automated backups
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.