mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
fix(memorydb): check for an existing cluster after claiming its name, so a create that just ended is seen (#7441)
* fix(memorydb): check for an existing cluster after claiming its name, so a create that just ended is seen * test(memorydb): wait for both racing creates to end before counting their outcomes * test(memorydb): build the racing creates' spec with the existing cluster helper
This commit is contained in:
1 parent
999abb3467
commit
31633804de
2 files changed
+77
-7
No files matched your search
@@ -101,18 +101,19 @@ public class MemoryDbService {
|
||||
throw new AwsException("InvalidParameterValueException", "ClusterName is required.", 400);
|
||||
}
|
||||
String resourceKey = key(region, name);
|
||||
if (clusters.get(resourceKey).isPresent() || legacyGet(clusters, name, region).isPresent()) {
|
||||
throw new AwsException("ClusterAlreadyExistsFault",
|
||||
"Cluster with specified name already exists.", 400);
|
||||
}
|
||||
// Claim the name for the whole provisioning attempt so a concurrent create can't race
|
||||
// ahead and be stopped by this request's handle-less rollback fallback.
|
||||
// ahead and be stopped by this request's handle-less rollback fallback. The existence
|
||||
// check follows the claim, so a create that ended before it is seen.
|
||||
if (!provisioningClusterNames.add(resourceKey)) {
|
||||
throw new AwsException("ClusterAlreadyExistsFault",
|
||||
"Cluster " + name + " is already being created.", 400);
|
||||
}
|
||||
|
||||
try {
|
||||
if (clusters.get(resourceKey).isPresent() || legacyGet(clusters, name, region).isPresent()) {
|
||||
throw new AwsException("ClusterAlreadyExistsFault",
|
||||
"Cluster with specified name already exists.", 400);
|
||||
}
|
||||
String aclName = spec.getAclName();
|
||||
if (aclName == null || aclName.isBlank()) {
|
||||
throw new AwsException("InvalidParameterValueException", "ACLName is required.", 400);
|
||||
|
||||
Reference in new issue
Block a user