mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(rds): propagate ModifyDBCluster master-password rotations to the backend and every proxy (#2727)
* fix(rds): propagate ModifyDBCluster master-password rotations to the backend and every proxy ModifyDBCluster only updated the stored password: the backend container kept the original credential and the cluster's and every member endpoint's auth proxy held stale start-time snapshots, so after a rotation no endpoint accepted the new password. Reuse the ModifyDBInstance mechanism: exec the change into the backend while the old credential is still known, then swap the password snapshot in place on the cluster proxy and each member proxy, updating the members' stored passwords to match (AWS applies the cluster master password to every member endpoint). Also pass the Docker container name instead of the instance id into execUntilSuccess from rotateMasterPassword, matching the log convention of the other call sites (review follow-up from #2709). * chore: retrigger CI after main repair
This commit is contained in:
1 parent
c6b9e4c34e
commit
895b59f1ee
3 files changed
+100
-11
No files matched your search
@@ -747,12 +747,13 @@ class RdsServiceTest {
|
||||
instance.setContainerId("container-1");
|
||||
instance.setContainerHost("10.0.0.5");
|
||||
instance.setContainerPort(3306);
|
||||
instance.setDockerVolumeName("volume-1");
|
||||
|
||||
DbInstance modified = rdsService.modifyDbInstance("mydb", "rotated-password", null, null);
|
||||
|
||||
assertEquals("rotated-password", modified.getMasterPassword());
|
||||
// The backend learns the new credential while the old one is still known...
|
||||
verify(containerManager).rotateMasterPassword("mydb", "container-1",
|
||||
verify(containerManager).rotateMasterPassword("volume-1", "container-1",
|
||||
DatabaseEngine.MYSQL, "admin", "original-password", "rotated-password");
|
||||
// ...and the running proxy's password snapshot is swapped in place, without a restart
|
||||
// (a stop/start would race the listener rebind and drop live connections).
|
||||
@@ -789,6 +790,59 @@ class RdsServiceTest {
|
||||
verify(proxyManager, never()).updateMasterPassword(anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbClusterPasswordRotationPropagatesToBackendAndEveryProxy() {
|
||||
DbCluster cluster = rdsService.createDbCluster("cluster1", "aurora-postgresql", "16.3",
|
||||
"admin", "original-password", "dbname", false, null);
|
||||
cluster.setContainerId("container-1");
|
||||
cluster.setDockerVolumeName("volume-1");
|
||||
DbInstance member = rdsService.createDbInstance("member-1", "aurora-postgresql", "16.3",
|
||||
"admin", "original-password", "dbname", "db.r5.large",
|
||||
20, false, null, null, "cluster1");
|
||||
|
||||
DbCluster modified = rdsService.modifyDbCluster("cluster1", "rotated-password", null);
|
||||
|
||||
assertEquals("rotated-password", modified.getMasterPassword());
|
||||
// The backend learns the new credential while the old one is still known...
|
||||
verify(containerManager).rotateMasterPassword("volume-1", "container-1",
|
||||
DatabaseEngine.POSTGRES, "admin", "original-password", "rotated-password");
|
||||
// ...and the cluster proxy AND every member endpoint's proxy swap their snapshots,
|
||||
// with the member's stored password updated so its validator accepts the new one.
|
||||
verify(proxyManager).updateMasterPassword(
|
||||
eq("rds-resource:" + cluster.getDbClusterArn()), eq("rotated-password"));
|
||||
verify(proxyManager).updateMasterPassword(
|
||||
eq("rds-resource:" + member.getDbInstanceArn()), eq("rotated-password"));
|
||||
assertEquals("rotated-password", member.getMasterPassword());
|
||||
verify(proxyManager, never()).stopProxy(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbClusterSamePasswordDoesNotTouchBackendOrProxy() {
|
||||
DbCluster cluster = rdsService.createDbCluster("cluster1", "aurora-postgresql", "16.3",
|
||||
"admin", "original-password", "dbname", false, null);
|
||||
cluster.setContainerId("container-1");
|
||||
|
||||
rdsService.modifyDbCluster("cluster1", "original-password", null);
|
||||
|
||||
verify(containerManager, never()).rotateMasterPassword(
|
||||
anyString(), anyString(), any(), anyString(), anyString(), anyString());
|
||||
verify(proxyManager, never()).updateMasterPassword(anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbClusterPasswordRotationSkipsBackendInMockMode() {
|
||||
when(config.services().rds().mock()).thenReturn(true);
|
||||
rdsService.createDbCluster("cluster1", "aurora-postgresql", "16.3",
|
||||
"admin", "original-password", "dbname", false, null);
|
||||
|
||||
DbCluster modified = rdsService.modifyDbCluster("cluster1", "rotated-password", null);
|
||||
|
||||
assertEquals("rotated-password", modified.getMasterPassword());
|
||||
verify(containerManager, never()).rotateMasterPassword(
|
||||
anyString(), anyString(), any(), anyString(), anyString(), anyString());
|
||||
verify(proxyManager, never()).updateMasterPassword(anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyDbInstanceCanToggleIamWithoutChangingPassword() {
|
||||
rdsService.createDbInstance("mydb", "postgres", "13",
|
||||
|
||||
Reference in new issue
Block a user