Skip to content

APPSRE9806: Adding replica removal validation #111

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions hooks/post_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def _validate_version_upgrade(self) -> None:
continue
current_version = u.change.before["engine_version"]
desired_version = u.change.after["engine_version"]
db_name = u.change.after["identifier"]
if current_version != desired_version:
valid_upgrade_targets = self.aws_api.get_rds_valid_upgrade_targets(
u.change.before["engine"], current_version
Expand All @@ -120,6 +121,11 @@ def _validate_version_upgrade(self) -> None:
self.errors.append(
"To enable major version upgrade, allow_major_version_upgrade attribute must be set to True"
)
# Read replica removal validation
if len(u.change.after["replicas"]) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

what change can happen in replicas? Do you have an example and add it to current tests?

Copy link
Contributor

@hemslo hemslo Mar 19, 2025

Choose a reason for hiding this comment

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

and we manage replica and source instances in 2 different terraform state, run in different jobs, so this limitation shouldn't be apply here.

Instead we can check if replicas already upgraded to new version, then allow source instance to upgrade.

self.errors.append(
f"The primary database, {db_name}, has a read replica associated with it. Please remove the replica before upgrading the primary database"
)

def _validate_deletion_protection_not_enabled_on_destroy(self) -> None:
for u in self.aws_db_instance_deletions:
Expand Down