fix(rds): register instances before starting auth proxy (#3467)

* fix(rds): register instances before starting auth proxy

* fix(rds): keep provisioning instances in creating state

---------

Co-authored-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
This commit is contained in:
XuJianandxujiantop-crypto authored and GitHub committed 2026-09-13 00:52:21 -04:00
1 parent 01ec7af8d5
commit 34efd8957a
2 files changed
+55 -9

No files matched your search

@@ -661,7 +661,7 @@ public class RdsService implements Resettable, ResourceProvider {
DbEndpoint endpoint = mock ? new DbEndpoint("localhost", proxyPort) : proxyEndpoint(proxyPort);
DbInstance instance = new DbInstance(id, engine, engineVersion, masterUsername, masterPassword,
dbName, dbInstanceClass, allocatedStorage, DbInstanceStatus.AVAILABLE,
dbName, dbInstanceClass, allocatedStorage, DbInstanceStatus.CREATING,
endpoint, iamEnabled, paramGroupName, dbClusterIdentifier, Instant.now(), proxyPort);
instance.setOptionGroupName(optionGroupName);
instance.setDbSubnetGroupName(dbSubnetGroupName);
@@ -688,15 +688,26 @@ public class RdsService implements Resettable, ResourceProvider {
attachManagedMasterUserSecret(instance, effectiveRegion, masterUserSecretKmsKeyId);
}
String accountId = accountIdFromArn(instance.getDbInstanceArn());
putInstanceForScope(accountId, effectiveRegion, id, instance);
if (!mock && hasBackend(backendHost, backendPort)) {
final String accountId = accountIdFromArn(instance.getDbInstanceArn());
final String instanceRegion = regionFromArn(instance.getDbInstanceArn());
proxyManager.startProxy(rdsResourceRelayKey(instance.getDbInstanceArn(), id),
engine, iamEnabled, proxyPort, backendHost, backendPort,
instance.getEndpoint().address(),
masterUsername, masterPassword, dbName,
(user, pw) -> validateDbPasswordForScope(
accountId, instanceRegion, id, user, pw));
try {
proxyManager.startProxy(rdsResourceRelayKey(instance.getDbInstanceArn(), id),
engine, iamEnabled, proxyPort, backendHost, backendPort,
instance.getEndpoint().address(),
masterUsername, masterPassword, dbName,
(user, pw) -> validateDbPasswordForScope(
accountId, instanceRegion, id, user, pw));
} catch (RuntimeException | Error e) {
try {
deleteInstanceForScope(accountId, effectiveRegion, id);
} catch (RuntimeException rollbackFailure) {
e.addSuppressed(rollbackFailure);
}
throw e;
}
}
if (dbClusterIdentifier != null && !dbClusterIdentifier.isBlank()) {
@@ -709,7 +720,8 @@ public class RdsService implements Resettable, ResourceProvider {
}
}
putInstanceForScope(currentAccountId(), effectiveRegion, id, instance);
instance.setStatus(DbInstanceStatus.AVAILABLE);
putInstanceForScope(accountId, effectiveRegion, id, instance);
LOG.infov("DB instance {0} created, engine={1}, endpoint={2}:{3}",
id, engine, endpoint.address(), String.valueOf(endpoint.port()));
return instance;