mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ec2): seed the default network before marking the scope seeded (#6637)
* fix(ec2): seed the default network before marking the scope seeded ensureDefaultResources added the account/region to the seeded set before seeding, so a concurrent first call returned at once and read a partial or empty default VPC. seed under a lock and mark the scope afterwards. * test(ec2): check the seed race with ParkingStore instead of a fixed wait The first call parks in its first subnet write and the test waits until the second call is blocked on the seed lock, so it fails at once on the old code and no longer sleeps two seconds.
This commit is contained in:
1 parent
0ec28aee68
commit
79e47cd7fc
2 files changed
+92
-1
No files matched your search
@@ -1427,9 +1427,21 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
public void ensureDefaultResources(String region) {
|
||||
String ownerAccountId = callerAccountId();
|
||||
String seedScope = ownerAccountId + "::" + region;
|
||||
if (!seededAccountRegions.add(seedScope)) {
|
||||
if (seededAccountRegions.contains(seedScope)) {
|
||||
return;
|
||||
}
|
||||
// Mark the scope only once it is seeded: a concurrent first call waits here instead of
|
||||
// reading a half-built default network (#6247).
|
||||
synchronized (seededAccountRegions) {
|
||||
if (seededAccountRegions.contains(seedScope)) {
|
||||
return;
|
||||
}
|
||||
seedDefaultResources(region, ownerAccountId);
|
||||
seededAccountRegions.add(seedScope);
|
||||
}
|
||||
}
|
||||
|
||||
private void seedDefaultResources(String region, String ownerAccountId) {
|
||||
List<Vpc> existingVpcs = vpcs.scan(k -> k.startsWith(region + "::"));
|
||||
// Already provisioned in a previous run and reloaded from persistent storage: the default
|
||||
// VPC (and everything else) is present, so don't re-seed and create duplicates (#1297).
|
||||
|
||||
Reference in new issue
Block a user