Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
fix: Clean up snapshots when cross region database replication fails (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mayitbeegh authored Feb 10, 2020
1 parent 4bf4036 commit a4f3d7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=4.12.0
version=4.12.1
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ public void run(XRegionDatabaseReplicationCommand command) {

log.info("Preparing to initiate copy of RDS DB snapshot: {} located in region: {} to region: {}",
sourceSnapshot.getDBClusterSnapshotIdentifier(), sourceRegion.getName(), targetRegion.getName());
DBClusterSnapshot copiedSnapshot = rdsService.copySnapshot(sourceSnapshot, sourceRegion, targetRegion);
rdsService.waitForSnapshotsToBecomeAvailable(copiedSnapshot, targetRegion);

rdsService.deleteSnapshot(sourceSnapshot, sourceRegion);
DBClusterSnapshot copiedSnapshot;
try {
copiedSnapshot = rdsService.copySnapshot(sourceSnapshot, sourceRegion, targetRegion);
rdsService.waitForSnapshotsToBecomeAvailable(copiedSnapshot, targetRegion);
} finally {
rdsService.deleteSnapshot(sourceSnapshot, sourceRegion);
}

String databasePassword = configStore.getCmsDatabasePassword()
.orElseThrow(() -> new RuntimeException("Expected the database password to exist"));
Expand Down Expand Up @@ -117,9 +120,9 @@ public void run(XRegionDatabaseReplicationCommand command) {
} else {
throw ase;
}
} finally {
rdsService.deleteSnapshot(copiedSnapshot, targetRegion);
}

rdsService.deleteSnapshot(copiedSnapshot, targetRegion);
}


Expand Down

0 comments on commit a4f3d7a

Please sign in to comment.