mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(docker): do not retry a call when the Docker socket does not exist (#5424)
* fix(docker): do not retry a call when the Docker socket does not exist Without a mounted Docker socket, every Docker call failed with "No such file or directory" and was retried six times, about 15 seconds. The ECS check for leftover containers runs at startup, so Floci opened port 4566 only after all the retries. A missing socket file does not come back on a retry, so DockerRetry no longer treats this error as transient. Closes #5342 * fix(docker): do not retry a call when access to the Docker socket is denied When the Docker socket exists but Floci may not open it, every Docker call failed with "Permission denied" and was retried six times, about 15 seconds. This also held each Docker call of the shutdown cleanup. A retry cannot change the permissions of the process, so DockerRetry no longer treats this error as transient, like a missing socket file.
This commit is contained in:
1 parent
cc129007e4
commit
dd6bf4cfcb
3 files changed
+73
-1
No files matched your search
@@ -73,7 +73,8 @@ public final class DockerRetry {
|
||||
/**
|
||||
* True when {@code t} (or any cause in its chain) is a transient docker I/O failure worth
|
||||
* retrying, an {@link IOException} such as {@code Broken pipe} / {@code Connection reset},
|
||||
* possibly wrapped by docker-java in a {@link RuntimeException}.
|
||||
* possibly wrapped by docker-java in a {@link RuntimeException}. A docker socket file that is
|
||||
* missing, or that this process may not open, is never transient.
|
||||
*/
|
||||
public static boolean isTransientIo(Throwable t) {
|
||||
// InterruptedIOException covers both a genuine thread interruption (masking it would
|
||||
@@ -94,6 +95,9 @@ public final class DockerRetry {
|
||||
if (c instanceof LocalFailure) {
|
||||
return false;
|
||||
}
|
||||
if (isUnusableSocket(c)) {
|
||||
return false;
|
||||
}
|
||||
if (c.getCause() == c) {
|
||||
break;
|
||||
}
|
||||
@@ -120,6 +124,22 @@ public final class DockerRetry {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* True when {@code t} reports that the docker socket file does not exist ({@code No such
|
||||
* file or directory}), as when Floci runs without a mounted docker socket, or that this
|
||||
* process may not open it ({@code Permission denied}). A retry cannot create the file or
|
||||
* change the process's permissions, so retrying only delays the failure: six attempts held
|
||||
* Floci's startup, and each docker call of its shutdown, for about 15 seconds.
|
||||
*/
|
||||
private static boolean isUnusableSocket(Throwable t) {
|
||||
String m = t.getMessage();
|
||||
if (m == null) {
|
||||
return false;
|
||||
}
|
||||
String lower = m.toLowerCase(Locale.ROOT);
|
||||
return lower.contains("no such file or directory") || lower.contains("permission denied");
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs {@code call}, retrying up to {@code maxAttempts} times on a transient docker I/O
|
||||
* error ({@link #isTransientIo}) with a capped exponential backoff between attempts
|
||||
|
||||
Reference in new issue
Block a user