fix(eks): reclaim anonymous volumes during node teardown (#7458)

Use existing strict volume-removing cleanup for EKS node deletion, capacity backups and failed replacements, and request anonymous-volume removal at the first failed-start cleanup, before replacement rollback. Preserve named-volume policy, the original startup failure and failed-removal retry ownership.

Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-11-03 21:33:34 -04:00
1 parent a796e2e58f
commit bc31464ab9
2 files changed
+64 -41

No files matched your search

@@ -794,7 +794,13 @@ public class EksClusterManager
try {
info = lifecycleManager.startCreated(containerId, spec);
} catch (Exception e) {
lifecycleManager.removeIfExists(containerName);
try {
lifecycleManager.removeIfExistsStrict(containerName, true);
} catch (RuntimeException cleanup) {
e.addSuppressed(cleanup);
LOG.warnv("Could not remove failed EKS container {0}; retaining it for cleanup retry: {1}",
containerName, cleanup.getMessage());
}
throw e;
}
@@ -933,7 +939,7 @@ public class EksClusterManager
.map(Container::getLabels).orElse(null));
DockerClient docker = lifecycleManager.getDockerClient();
try {
lifecycleManager.removeIfExistsStrict(backupName);
lifecycleManager.removeIfExistsStrict(backupName, true);
} catch (RuntimeException cleanup) {
LOG.warnv("Could not clear prior EKS capacity backup for cluster {0}: {1}; keeping current node",
cluster.getName(), cleanup.getMessage());
@@ -958,7 +964,7 @@ public class EksClusterManager
return false;
}
try {
lifecycleManager.removeIfExistsStrict(containerName);
lifecycleManager.removeIfExistsStrict(containerName, true);
docker.renameContainerCmd(oldId).withName(containerName).exec();
if (!adoptSurvivingCluster(cluster, oldId, oldCertificateHost)) {
throw new IllegalStateException("Could not adopt previous EKS container " + oldId);
@@ -970,7 +976,7 @@ public class EksClusterManager
return false;
}
try {
lifecycleManager.removeIfExistsStrict(backupName);
lifecycleManager.removeIfExistsStrict(backupName, true);
} catch (RuntimeException cleanup) {
LOG.warnv("EKS cluster {0} replacement is running, but its stopped capacity backup"
+ " could not be removed: {1}; cluster deletion will retry",
@@ -1121,7 +1127,7 @@ public class EksClusterManager
// Strict: a container Docker could not remove may still be running and publishing the
// port, so the delete fails and keeps the cluster record, its metadata endpoint, log
// handle and port reservation; a retried delete releases them once the container is gone.
lifecycleManager.stopAndRemoveStrict(cluster.getContainerId(), logStream);
lifecycleManager.stopAndRemoveStrict(cluster.getContainerId(), logStream, 5, true);
unregisterMetadataEndpoint(cluster);
// Removed by value so an overlapping delete cannot drop a handle it does not own.
if (logStream != null) {
@@ -1140,7 +1146,7 @@ public class EksClusterManager
if (cluster.getDockerName() != null) {
// A failed backup cleanup must not leave the live node running. Keep the cluster
// record so explicit deletion can be retried once Docker accepts the removal.
lifecycleManager.removeIfExistsStrict(capacityBackupName(cluster));
lifecycleManager.removeIfExistsStrict(capacityBackupName(cluster), true);
}
ContainerStorageHelper.removeNamedVolume(config, lifecycleManager, clusterResourceName(cluster));
LOG.infov("Stopped k3s container for cluster {0}", cluster.getName());