mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(rds): honor Port on cluster snapshot restore (#4326)
* fix(rds): honor requested port when restoring a cluster snapshot Reserve an explicit RestoreDBClusterFromSnapshot port for the cluster endpoint and proxy, validate its AWS range, and reject local port collisions. Keep automatic allocation when Port is omitted. * fix(rds): keep requested ports within published proxy range * fix(rds): reject occupied requested ports and preserve handler calls
This commit is contained in:
1 parent
c357d37fa9
commit
df67d421f9
5 files changed
+367
-27
No files matched your search
@@ -220,11 +220,19 @@ public class RdsQueryHandler {
|
||||
try {
|
||||
DbInstanceSettings settings = instanceSettings(params);
|
||||
List<String> vpcSecurityGroupIds = vpcSecurityGroupIds(params);
|
||||
DbInstance instance = service.createDbInstance(id, engine, engineVersion, masterUsername,
|
||||
masterPassword, dbName, dbInstanceClass, allocatedStorage, iamEnabled,
|
||||
paramGroupName, dbSubnetGroupName, dbClusterIdentifier, availabilityZone, multiAz,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, tags, vpcSecurityGroupIds,
|
||||
optionGroupName, region, autoMinorVersionUpgrade, settings, publiclyAccessible);
|
||||
Integer requestedPort = parseIntegerParam(params, "Port");
|
||||
DbInstance instance = requestedPort == null
|
||||
? service.createDbInstance(id, engine, engineVersion, masterUsername,
|
||||
masterPassword, dbName, dbInstanceClass, allocatedStorage, iamEnabled,
|
||||
paramGroupName, dbSubnetGroupName, dbClusterIdentifier, availabilityZone, multiAz,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, tags, vpcSecurityGroupIds,
|
||||
optionGroupName, region, autoMinorVersionUpgrade, settings, publiclyAccessible)
|
||||
: service.createDbInstance(id, engine, engineVersion, masterUsername,
|
||||
masterPassword, dbName, dbInstanceClass, allocatedStorage, iamEnabled,
|
||||
paramGroupName, dbSubnetGroupName, dbClusterIdentifier, availabilityZone, multiAz,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, tags, vpcSecurityGroupIds,
|
||||
optionGroupName, region, autoMinorVersionUpgrade, settings, publiclyAccessible,
|
||||
requestedPort);
|
||||
String result = dbInstanceXml(instance);
|
||||
return Response.ok(AwsQueryResponse.envelope("CreateDBInstance", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
@@ -901,18 +909,36 @@ public class RdsQueryHandler {
|
||||
Double serverlessV2Max = parseDoubleParam(params, "ServerlessV2ScalingConfiguration.MaxCapacity");
|
||||
Integer serverlessV2SecondsUntilAutoPause = parseIntegerParam(
|
||||
params, "ServerlessV2ScalingConfiguration.SecondsUntilAutoPause");
|
||||
Integer requestedPort = parseIntegerParam(params, "Port");
|
||||
String globalClusterIdentifier = params.getFirst("GlobalClusterIdentifier");
|
||||
DbCluster cluster = globalClusterIdentifier != null && !globalClusterIdentifier.isBlank()
|
||||
DbCluster cluster;
|
||||
if (globalClusterIdentifier != null && !globalClusterIdentifier.isBlank()) {
|
||||
cluster = requestedPort == null
|
||||
? service.createDbClusterInGlobalCluster(globalClusterIdentifier, id, engine,
|
||||
params.getFirst("EngineVersion"), masterUsername, masterPassword, databaseName,
|
||||
iamEnabled, paramGroupName, dbSubnetGroupName, availabilityZone, multiAz, region,
|
||||
serverlessV2Min, serverlessV2Max, serverlessV2SecondsUntilAutoPause,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted)
|
||||
: service.createDbClusterInGlobalCluster(globalClusterIdentifier, id, engine,
|
||||
params.getFirst("EngineVersion"), masterUsername, masterPassword, databaseName,
|
||||
iamEnabled, paramGroupName, dbSubnetGroupName, availabilityZone, multiAz, region,
|
||||
serverlessV2Min, serverlessV2Max, serverlessV2SecondsUntilAutoPause,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted,
|
||||
requestedPort);
|
||||
} else {
|
||||
cluster = requestedPort == null
|
||||
? service.createDbCluster(id, engine, engineVersion, masterUsername,
|
||||
masterPassword, databaseName, iamEnabled, paramGroupName,
|
||||
dbSubnetGroupName, availabilityZone, multiAz, region,
|
||||
serverlessV2Min, serverlessV2Max, serverlessV2SecondsUntilAutoPause,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted)
|
||||
: service.createDbCluster(id, engine, engineVersion, masterUsername,
|
||||
masterPassword, databaseName, iamEnabled, paramGroupName,
|
||||
dbSubnetGroupName, availabilityZone, multiAz, region,
|
||||
serverlessV2Min, serverlessV2Max, serverlessV2SecondsUntilAutoPause,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted);
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode, storageEncrypted,
|
||||
requestedPort);
|
||||
}
|
||||
String result = dbClusterXml(cluster);
|
||||
return Response.ok(AwsQueryResponse.envelope("CreateDBCluster", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
@@ -1574,17 +1600,24 @@ public class RdsQueryHandler {
|
||||
boolean multiAz = multiAzStr != null && Boolean.parseBoolean(multiAzStr);
|
||||
String dbSubnetGroupName = params.getFirst("DBSubnetGroupName");
|
||||
|
||||
java.util.List<String> vpcSecurityGroupIds = new java.util.ArrayList<>();
|
||||
List<String> vpcSecurityGroupIds = new ArrayList<>();
|
||||
for (int i = 1; ; i++) {
|
||||
String sg = params.getFirst("VpcSecurityGroupIds.VpcSecurityGroupId." + i);
|
||||
if (sg == null) break;
|
||||
vpcSecurityGroupIds.add(sg);
|
||||
}
|
||||
|
||||
java.util.Map<String, String> tags = parseTags(params);
|
||||
Map<String, String> tags = parseTags(params);
|
||||
|
||||
try {
|
||||
DbInstance instance = service.restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass, availabilityZone, multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags, region);
|
||||
Integer requestedPort = parseIntegerParam(params, "Port");
|
||||
DbInstance instance = requestedPort == null
|
||||
? service.restoreDbInstanceFromDbSnapshot(instanceId, snapshotId,
|
||||
dbInstanceClass, availabilityZone, multiAz, dbSubnetGroupName,
|
||||
vpcSecurityGroupIds, tags, region)
|
||||
: service.restoreDbInstanceFromDbSnapshot(instanceId, snapshotId,
|
||||
dbInstanceClass, availabilityZone, multiAz, dbSubnetGroupName,
|
||||
vpcSecurityGroupIds, tags, region, requestedPort);
|
||||
String result = dbInstanceXml(instance);
|
||||
return Response.ok(AwsQueryResponse.envelope("RestoreDBInstanceFromDBSnapshot", AwsNamespaces.RDS, result)).build();
|
||||
} catch (AwsException e) {
|
||||
|
||||
@@ -592,6 +592,29 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
boolean autoMinorVersionUpgrade,
|
||||
DbInstanceSettings settings,
|
||||
Boolean publiclyAccessible) {
|
||||
return createDbInstance(id, engineParam, engineVersion, masterUsername, masterPassword,
|
||||
dbName, dbInstanceClass, allocatedStorage, iamEnabled, paramGroupName,
|
||||
dbSubnetGroupName, dbClusterIdentifier, availabilityZone, multiAz,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, tags, vpcSecurityGroupIds,
|
||||
optionGroupName, region, autoMinorVersionUpgrade, settings, publiclyAccessible, null);
|
||||
}
|
||||
|
||||
public DbInstance createDbInstance(String id, String engineParam, String engineVersion,
|
||||
String masterUsername, String masterPassword,
|
||||
String dbName, String dbInstanceClass,
|
||||
int allocatedStorage, boolean iamEnabled,
|
||||
String paramGroupName, String dbSubnetGroupName,
|
||||
String dbClusterIdentifier, String availabilityZone,
|
||||
boolean multiAz, boolean manageMasterUserPassword,
|
||||
String masterUserSecretKmsKeyId,
|
||||
Map<String, String> tags,
|
||||
List<String> vpcSecurityGroupIds,
|
||||
String optionGroupName,
|
||||
String region,
|
||||
boolean autoMinorVersionUpgrade,
|
||||
DbInstanceSettings settings,
|
||||
Boolean publiclyAccessible,
|
||||
Integer requestedPort) {
|
||||
validateInstanceSettings(settings);
|
||||
String provisioningKey = "instance:" + currentAccountId() + ":"
|
||||
+ dbResourceKey(effectiveRegion(region), id);
|
||||
@@ -605,7 +628,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
paramGroupName, dbSubnetGroupName, dbClusterIdentifier, availabilityZone,
|
||||
multiAz, manageMasterUserPassword, masterUserSecretKmsKeyId, tags,
|
||||
vpcSecurityGroupIds, optionGroupName, region, autoMinorVersionUpgrade,
|
||||
settings, publiclyAccessible);
|
||||
settings, publiclyAccessible, requestedPort);
|
||||
} finally {
|
||||
provisioningIds.remove(provisioningKey);
|
||||
}
|
||||
@@ -625,7 +648,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
String region,
|
||||
boolean autoMinorVersionUpgrade,
|
||||
DbInstanceSettings settings,
|
||||
Boolean publiclyAccessible) {
|
||||
Boolean publiclyAccessible, Integer requestedPort) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String dbiResourceId = "db-" + java.util.UUID.randomUUID().toString()
|
||||
.replace("-", "").substring(0, 24).toUpperCase();
|
||||
@@ -653,9 +676,6 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
DbInstanceSettings.validateMonitoringPairOnCreate(
|
||||
settings.monitoringInterval(), settings.monitoringRoleArn());
|
||||
boolean mock = config.services().rds().mock();
|
||||
// Always reserve a unique port (even in mock) so endpoints stay distinct and usedPorts
|
||||
// is consistent; mock mode only skips starting the container and auth proxy.
|
||||
int proxyPort = allocateProxyPort();
|
||||
if (masterUsername == null || masterUsername.isBlank()) {
|
||||
masterUsername = "root";
|
||||
} else if (masterUsername.length() > engine.maxMasterUsernameLength()
|
||||
@@ -666,6 +686,9 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
if (manageMasterUserPassword && (masterPassword == null || masterPassword.isBlank())) {
|
||||
masterPassword = generatedMasterPassword();
|
||||
}
|
||||
// Always reserve a unique port (even in mock) so endpoints stay distinct and usedPorts
|
||||
// is consistent; mock mode only skips starting the container and auth proxy.
|
||||
int proxyPort = reserveProxyPort(requestedPort);
|
||||
|
||||
String backendHost = null;
|
||||
int backendPort = 0;
|
||||
@@ -1067,15 +1090,24 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
|
||||
private record SnapshotReference(String accountId, String region, DbSnapshot snapshot) {}
|
||||
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass, String availabilityZone, boolean multiAz, String dbSubnetGroupName, java.util.List<String> vpcSecurityGroupIds, java.util.Map<String, String> tags) {
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass, String availabilityZone, boolean multiAz, String dbSubnetGroupName, List<String> vpcSecurityGroupIds, Map<String, String> tags) {
|
||||
return restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass, availabilityZone,
|
||||
multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass,
|
||||
String availabilityZone, boolean multiAz, String dbSubnetGroupName,
|
||||
java.util.List<String> vpcSecurityGroupIds,
|
||||
java.util.Map<String, String> tags, String region) {
|
||||
List<String> vpcSecurityGroupIds,
|
||||
Map<String, String> tags, String region) {
|
||||
return restoreDbInstanceFromDbSnapshot(instanceId, snapshotId, dbInstanceClass,
|
||||
availabilityZone, multiAz, dbSubnetGroupName, vpcSecurityGroupIds, tags, region, null);
|
||||
}
|
||||
|
||||
public DbInstance restoreDbInstanceFromDbSnapshot(String instanceId, String snapshotId, String dbInstanceClass,
|
||||
String availabilityZone, boolean multiAz, String dbSubnetGroupName,
|
||||
List<String> vpcSecurityGroupIds,
|
||||
Map<String, String> tags, String region,
|
||||
Integer requestedPort) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
DbSnapshot snapshot = Optional.ofNullable(findSnapshotForScope(currentAccountId(), effectiveRegion, snapshotId))
|
||||
.orElseThrow(() -> new AwsException("DBSnapshotNotFound", "DBSnapshot " + snapshotId + " not found.", 404));
|
||||
@@ -1093,8 +1125,8 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
DbInstance instance = createDbInstance(instanceId, snapshot.getEngine().name().toLowerCase(), snapshot.getEngineVersion(),
|
||||
snapshot.getMasterUsername(), snapshot.getMasterPassword(),
|
||||
snapshot.getDbName(), targetClass, snapshot.getAllocatedStorage(), snapshot.isIamDatabaseAuthenticationEnabled(),
|
||||
null, dbSubnetGroupName, null, availabilityZone, multiAz, false, null, tags,
|
||||
vpcSecurityGroupIds, null, effectiveRegion, true, restoreSettings);
|
||||
null, dbSubnetGroupName, null, availabilityZone, multiAz, false, null, tags, vpcSecurityGroupIds,
|
||||
null, effectiveRegion, true, restoreSettings, null, requestedPort);
|
||||
|
||||
if (!config.services().rds().mock()) {
|
||||
try {
|
||||
@@ -1695,7 +1727,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
.orElseThrow(() -> new AwsException("DBClusterSnapshotNotFoundFault",
|
||||
"DB cluster snapshot data for " + resolvedSnapshotId + " not found.", 404));
|
||||
|
||||
DbCluster cluster = createDbCluster(clusterId, engine,
|
||||
DbCluster cluster = createDbClusterWithPort(clusterId, engine,
|
||||
engineVersion != null && !engineVersion.isBlank() ? engineVersion : snapshot.getEngineVersion(),
|
||||
snapshot.getMasterUsername(), snapshot.getMasterPassword(),
|
||||
databaseName != null && !databaseName.isBlank() ? databaseName : snapshot.getDatabaseName(),
|
||||
@@ -1703,7 +1735,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
parameterGroupName, dbSubnetGroupName, availabilityZone, false, effectiveRegion,
|
||||
null, null, null, false, null,
|
||||
engineMode != null && !engineMode.isBlank() ? engineMode : snapshot.getEngineMode(),
|
||||
snapshot.isStorageEncrypted());
|
||||
snapshot.isStorageEncrypted(), port);
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
cluster.getTags().putAll(tags);
|
||||
putClusterForScope(accountId, effectiveRegion, clusterId, cluster);
|
||||
@@ -3394,6 +3426,38 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted) {
|
||||
return createDbCluster(id, engineParam, engineVersion, masterUsername, masterPassword,
|
||||
databaseName, iamEnabled, paramGroupName, dbSubnetGroupName, availabilityZone,
|
||||
multiAz, region, serverlessV2MinCapacity, serverlessV2MaxCapacity,
|
||||
serverlessV2SecondsUntilAutoPause, manageMasterUserPassword, masterUserSecretKmsKeyId,
|
||||
engineMode, storageEncrypted, null);
|
||||
}
|
||||
|
||||
public DbCluster createDbCluster(String id, String engineParam, String engineVersion,
|
||||
String masterUsername, String masterPassword,
|
||||
String databaseName, boolean iamEnabled,
|
||||
String paramGroupName, String dbSubnetGroupName,
|
||||
String availabilityZone, boolean multiAz, String region,
|
||||
Double serverlessV2MinCapacity, Double serverlessV2MaxCapacity,
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted, Integer requestedPort) {
|
||||
return createDbClusterWithPort(id, engineParam, engineVersion, masterUsername, masterPassword,
|
||||
databaseName, iamEnabled, paramGroupName, dbSubnetGroupName, availabilityZone,
|
||||
multiAz, region, serverlessV2MinCapacity, serverlessV2MaxCapacity,
|
||||
serverlessV2SecondsUntilAutoPause, manageMasterUserPassword, masterUserSecretKmsKeyId,
|
||||
engineMode, storageEncrypted, requestedPort);
|
||||
}
|
||||
|
||||
private DbCluster createDbClusterWithPort(String id, String engineParam, String engineVersion,
|
||||
String masterUsername, String masterPassword,
|
||||
String databaseName, boolean iamEnabled,
|
||||
String paramGroupName, String dbSubnetGroupName,
|
||||
String availabilityZone, boolean multiAz, String region,
|
||||
Double serverlessV2MinCapacity, Double serverlessV2MaxCapacity,
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted, Integer requestedPort) {
|
||||
String provisioningKey = "cluster:" + currentAccountId() + ":"
|
||||
+ dbResourceKey(effectiveRegion(region), id);
|
||||
if (!provisioningIds.add(provisioningKey)) {
|
||||
@@ -3405,7 +3469,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
databaseName, iamEnabled, paramGroupName, dbSubnetGroupName, availabilityZone,
|
||||
multiAz, region, serverlessV2MinCapacity, serverlessV2MaxCapacity,
|
||||
serverlessV2SecondsUntilAutoPause, manageMasterUserPassword, masterUserSecretKmsKeyId,
|
||||
engineMode, storageEncrypted);
|
||||
engineMode, storageEncrypted, requestedPort);
|
||||
} finally {
|
||||
provisioningIds.remove(provisioningKey);
|
||||
}
|
||||
@@ -3419,7 +3483,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
Double serverlessV2MinCapacity, Double serverlessV2MaxCapacity,
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted) {
|
||||
String engineMode, boolean storageEncrypted, Integer requestedPort) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String clusterResourceId = "cluster-" + java.util.UUID.randomUUID().toString()
|
||||
.replace("-", "").substring(0, 24).toUpperCase();
|
||||
@@ -3442,7 +3506,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
boolean mock = config.services().rds().mock();
|
||||
// Always reserve a unique port (even in mock) so endpoints stay distinct and usedPorts
|
||||
// is consistent; mock mode only skips starting the container and auth proxy.
|
||||
int proxyPort = allocateProxyPort();
|
||||
int proxyPort = reserveProxyPort(requestedPort);
|
||||
if (manageMasterUserPassword && (masterPassword == null || masterPassword.isBlank())) {
|
||||
masterPassword = generatedMasterPassword();
|
||||
}
|
||||
@@ -4083,6 +4147,23 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted) {
|
||||
return createDbClusterInGlobalCluster(globalClusterIdentifier, id, engineParam, engineVersion,
|
||||
masterUsername, masterPassword, databaseName, iamEnabled, paramGroupName,
|
||||
dbSubnetGroupName, availabilityZone, multiAz, region, serverlessV2MinCapacity,
|
||||
serverlessV2MaxCapacity, serverlessV2SecondsUntilAutoPause, manageMasterUserPassword,
|
||||
masterUserSecretKmsKeyId, engineMode, storageEncrypted, null);
|
||||
}
|
||||
|
||||
public DbCluster createDbClusterInGlobalCluster(String globalClusterIdentifier, String id,
|
||||
String engineParam, String engineVersion,
|
||||
String masterUsername, String masterPassword,
|
||||
String databaseName, boolean iamEnabled,
|
||||
String paramGroupName, String dbSubnetGroupName,
|
||||
String availabilityZone, boolean multiAz, String region,
|
||||
Double serverlessV2MinCapacity, Double serverlessV2MaxCapacity,
|
||||
Integer serverlessV2SecondsUntilAutoPause,
|
||||
boolean manageMasterUserPassword, String masterUserSecretKmsKeyId,
|
||||
String engineMode, boolean storageEncrypted, Integer requestedPort) {
|
||||
String effectiveRegion = effectiveRegion(region);
|
||||
String accountId = currentAccountId();
|
||||
GlobalCluster global = requireGlobalCluster(accountId, globalClusterIdentifier);
|
||||
@@ -4103,7 +4184,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
paramGroupName, dbSubnetGroupName, availabilityZone, multiAz, effectiveRegion,
|
||||
serverlessV2MinCapacity, serverlessV2MaxCapacity, serverlessV2SecondsUntilAutoPause,
|
||||
manageMasterUserPassword, masterUserSecretKmsKeyId, engineMode,
|
||||
storageEncrypted || global.isStorageEncrypted());
|
||||
storageEncrypted || global.isStorageEncrypted(), requestedPort);
|
||||
} else {
|
||||
if (hasText(masterUsername) || hasText(masterPassword) || manageMasterUserPassword) {
|
||||
throw new AwsException("InvalidParameterCombination",
|
||||
@@ -4138,7 +4219,7 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
primary.getDatabaseName(), iamEnabled, paramGroupName, dbSubnetGroupName,
|
||||
availabilityZone, multiAz, effectiveRegion, serverlessV2MinCapacity,
|
||||
serverlessV2MaxCapacity, serverlessV2SecondsUntilAutoPause, false, null,
|
||||
engineMode, primary.isStorageEncrypted());
|
||||
engineMode, primary.isStorageEncrypted(), requestedPort);
|
||||
}
|
||||
try {
|
||||
attachToGlobalCluster(accountId, global.getGlobalClusterIdentifier(), cluster, primary == null);
|
||||
@@ -6297,6 +6378,25 @@ public class RdsService implements Resettable, ResourceProvider {
|
||||
return imageName + ":" + requestedTag;
|
||||
}
|
||||
|
||||
private int reserveProxyPort(Integer requestedPort) {
|
||||
if (requestedPort == null) {
|
||||
return allocateProxyPort();
|
||||
}
|
||||
if (requestedPort < 1150 || requestedPort > 65535) {
|
||||
throw new AwsException("InvalidParameterValue", "Port must be between 1150 and 65535.", 400);
|
||||
}
|
||||
int base = config.services().rds().proxyBasePort();
|
||||
int max = config.services().rds().proxyMaxPort();
|
||||
if (requestedPort >= base && requestedPort <= max) {
|
||||
if (!usedPorts.add(requestedPort)) {
|
||||
throw new AwsException("InvalidParameterValue",
|
||||
"Port " + requestedPort + " is already in use by another RDS resource.", 400);
|
||||
}
|
||||
return requestedPort;
|
||||
}
|
||||
return allocateProxyPort();
|
||||
}
|
||||
|
||||
private int allocateProxyPort() {
|
||||
int base = config.services().rds().proxyBasePort();
|
||||
int max = config.services().rds().proxyMaxPort();
|
||||
|
||||
Reference in new issue
Block a user