mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(docker): avoid global teardown admission waits (#6581)
* fix(docker): avoid global teardown admission waits * test(docker): observe teardown stop execution * test(ec2): match account-aware private IP allocation * chore(docker): remove obsolete teardown admission wrappers
This commit is contained in:
1 parent
94fcf5cbf3
commit
f5453b9585
2 files changed
+38
-107
No files matched your search
@@ -55,7 +55,6 @@ import java.util.OptionalLong;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -92,8 +91,6 @@ public class ContainerLifecycleManager {
|
||||
/** Host interface a port marked loopback-only publishes on. */
|
||||
private static final String LOOPBACK_HOST_IP = "127.0.0.1";
|
||||
|
||||
private final Semaphore teardownSlots = new Semaphore(8, true);
|
||||
|
||||
private final DockerClient dockerClient;
|
||||
private final ImageCacheService imageCacheService;
|
||||
private final ContainerDetector containerDetector;
|
||||
@@ -618,11 +615,7 @@ public class ContainerLifecycleManager {
|
||||
* SIGTERM before Docker sends SIGKILL. Must be a non-negative integer.
|
||||
*/
|
||||
public void stopAndRemove(String containerId, Closeable logStream, int stopTimeoutSeconds) {
|
||||
withTeardownSlot(() -> stopAndRemoveAdmitted(containerId, logStream, stopTimeoutSeconds));
|
||||
}
|
||||
|
||||
private void stopAndRemoveAdmitted(String containerId, Closeable logStream, int stopTimeoutSeconds) {
|
||||
boolean stoppedOrMissing = stopAdmitted(containerId, stopTimeoutSeconds);
|
||||
boolean stoppedOrMissing = stop(containerId, stopTimeoutSeconds);
|
||||
|
||||
// Force removal is the recovery path when Docker could not stop the container cleanly. It also
|
||||
// terminates the follow-log transport, allowing its terminal callback to drain the final tail.
|
||||
@@ -649,12 +642,9 @@ public class ContainerLifecycleManager {
|
||||
*
|
||||
* @param stopTimeoutSeconds seconds to wait for the container to stop cleanly after
|
||||
* SIGTERM before Docker sends SIGKILL. Must be a non-negative integer.
|
||||
* @return whether the container is stopped or already missing
|
||||
*/
|
||||
public void stop(String containerId, int stopTimeoutSeconds) {
|
||||
withTeardownSlot(() -> stopAdmitted(containerId, stopTimeoutSeconds));
|
||||
}
|
||||
|
||||
private boolean stopAdmitted(String containerId, int stopTimeoutSeconds) {
|
||||
public boolean stop(String containerId, int stopTimeoutSeconds) {
|
||||
LOG.infov("Stopping container {0}", containerId);
|
||||
try {
|
||||
dockerClient.stopContainerCmd(containerId).withTimeout(stopTimeoutSeconds).exec();
|
||||
@@ -705,12 +695,6 @@ public class ContainerLifecycleManager {
|
||||
/** Strict teardown that can also reclaim the container's anonymous volumes. */
|
||||
public void stopAndRemoveStrict(String containerId, Closeable logStream, int stopTimeoutSeconds,
|
||||
boolean removeAnonymousVolumes) {
|
||||
withTeardownSlot(() -> stopAndRemoveStrictAdmitted(
|
||||
containerId, logStream, stopTimeoutSeconds, removeAnonymousVolumes));
|
||||
}
|
||||
|
||||
private void stopAndRemoveStrictAdmitted(String containerId, Closeable logStream, int stopTimeoutSeconds,
|
||||
boolean removeAnonymousVolumes) {
|
||||
LOG.infov("Stopping container {0}", containerId);
|
||||
|
||||
Exception stopFailure = null;
|
||||
@@ -774,15 +758,6 @@ public class ContainerLifecycleManager {
|
||||
return presenceOf(containerId) == ContainerPresence.ABSENT;
|
||||
}
|
||||
|
||||
private void withTeardownSlot(Runnable stopAndRemove) {
|
||||
teardownSlots.acquireUninterruptibly();
|
||||
try {
|
||||
stopAndRemove.run();
|
||||
} finally {
|
||||
teardownSlots.release();
|
||||
}
|
||||
}
|
||||
|
||||
private void closeLogStreamIfPresent(Closeable logStream) {
|
||||
if (logStream != null) {
|
||||
closeLogStreamAfterContainerStop(logStream);
|
||||
|
||||
Reference in new issue
Block a user