fix(ec2): serialize VPC deletion with Docker network creation (#7470)

Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

(cherry picked from commit 7797b47de690c157d056866de6e51eaa7ae86301)

Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Jackson PriceandAndre Kurait authored and GitHub committed 2026-11-03 22:49:24 -04:00
1 parent 4a2c0a8a5b
commit d481f8396c
3 files changed
+72 -3

No files matched your search

@@ -662,6 +662,9 @@ public class VpcNetworkManager {
/** @return the network name, or null when creation failed */
private String materialise(VpcBinding vpc) {
synchronized (vpc) {
if (bindings.get(key(vpc.region, vpc.vpcId)) != vpc) {
return null;
}
if (vpc.created) {
attachCurrentContainer(vpc, null);
return vpc.networkName;
@@ -848,8 +851,12 @@ public class VpcNetworkManager {
// An upgrade can leave both spellings behind, so every one noted is removed.
Set<String> previousRunNetworks = networksFromPreviousRun.remove(key(region, vpcId));
Set<String> networkNames = new LinkedHashSet<>();
if (vpc.created) {
networkNames.add(vpc.networkName);
synchronized (vpc) {
// An in-flight Docker create must finish before its network is collected for removal.
// The retired binding cannot create another network.
if (vpc.created) {
networkNames.add(vpc.networkName);
}
}
if (previousRunNetworks != null) {
networkNames.addAll(previousRunNetworks);