Skip to content

Conversation

@jtgorny
Copy link

@jtgorny jtgorny commented Jan 2, 2026

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.

@ack-prow ack-prow bot requested review from jlbutler and knottnt January 2, 2026 01:20
@ack-prow
Copy link

ack-prow bot commented Jan 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jtgorny
Once this PR has been reviewed and has the lgtm label, please assign michaelhtm for approval by writing /assign @michaelhtm in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 2, 2026
@ack-prow
Copy link

ack-prow bot commented Jan 2, 2026

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

Copy link
Contributor

@knottnt knottnt left a 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.

Comment on lines +539 to +540
import boto3
rds_client = boto3.client('rds')
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

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

Single cross-region

Comment on lines +714 to +715
latestEnabled := latest.ko.Status.DBInstanceAutomatedBackupsReplications != nil &&
len(latest.ko.Status.DBInstanceAutomatedBackupsReplications) > 0
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants