diff --git a/.github/scripts/smoke-binary.sh b/.github/scripts/smoke-binary.sh
index 35885540d3..1ede2985c1 100755
--- a/.github/scripts/smoke-binary.sh
+++ b/.github/scripts/smoke-binary.sh
@@ -44,8 +44,17 @@ trap cleanup EXIT
fail() {
echo "FAIL: $*" >&2
- echo "--- floci log (last 60 lines) ---" >&2
- tail -n 60 "$LOG" >&2 || true
+ # The first exception of a failed startup is at the top of the log and its cause chain at the
+ # bottom, so a long log shows both ends.
+ if [ "$(wc -l < "$LOG" 2>/dev/null || echo 0)" -le 200 ]; then
+ echo "--- floci log ---" >&2
+ cat "$LOG" >&2 || true
+ else
+ echo "--- floci log (first 100 lines) ---" >&2
+ head -n 100 "$LOG" >&2 || true
+ echo "--- floci log (last 100 lines) ---" >&2
+ tail -n 100 "$LOG" >&2 || true
+ fi
exit 1
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/docker/DockerRetry.java b/src/main/java/io/github/hectorvent/floci/core/common/docker/DockerRetry.java
index f784d68af0..6dede710f5 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/docker/DockerRetry.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/docker/DockerRetry.java
@@ -5,6 +5,8 @@ import org.jboss.logging.Logger;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.NoSuchFileException;
import java.util.Locale;
/**
@@ -129,9 +131,14 @@ public final class DockerRetry {
* 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.
+ * Floci's startup, and each docker call of its shutdown, for about 15 seconds. A Windows named
+ * pipe reports the same two cases as {@link NoSuchFileException} and {@link AccessDeniedException},
+ * whose message is only the pipe's name.
*/
private static boolean isUnusableSocket(Throwable t) {
+ if (t instanceof NoSuchFileException || t instanceof AccessDeniedException) {
+ return true;
+ }
String m = t.getMessage();
if (m == null) {
return false;
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/docker/FailFastNamedPipeSocket.java b/src/main/java/io/github/hectorvent/floci/core/common/docker/FailFastNamedPipeSocket.java
new file mode 100644
index 0000000000..1e5345705d
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/core/common/docker/FailFastNamedPipeSocket.java
@@ -0,0 +1,49 @@
+package io.github.hectorvent.floci.core.common.docker;
+
+import com.github.dockerjava.transport.NamedPipeSocket;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+
+/**
+ * A docker-java {@link NamedPipeSocket} that fails at once when the pipe does not exist.
+ *
+ *
docker-java's {@code connect} retries the open on every {@link FileSystemException} until the
+ * connect timeout passes, waiting for a free pipe instance in between. That wait is right for a busy
+ * pipe ({@code ERROR_PIPE_BUSY}), but a missing pipe, Docker not running, is never going to appear
+ * within the timeout: on a Windows host without Docker every Docker call spent the full 30 seconds in
+ * that loop, and startup never got as far as answering {@code /_floci/health}. This socket opens the
+ * pipe once first. A missing pipe, or one this process may not open, fails with that exception, which
+ * {@link DockerRetry} does not retry; any other failure, a busy pipe, falls through to docker-java's
+ * wait loop. When the probe opens the pipe it is closed again and docker-java opens its own channel,
+ * since that channel is private to {@code NamedPipeSocket}.
+ */
+final class FailFastNamedPipeSocket extends NamedPipeSocket {
+
+ private final String pipeName;
+
+ FailFastNamedPipeSocket(String pipeName) {
+ super(pipeName);
+ this.pipeName = pipeName;
+ }
+
+ @Override
+ public void connect(SocketAddress endpoint, int timeout) throws IOException {
+ try (AsynchronousFileChannel probe = AsynchronousFileChannel.open(
+ Paths.get(pipeName), StandardOpenOption.READ, StandardOpenOption.WRITE)) {
+ // The pipe exists and had a free instance; docker-java reopens it below.
+ } catch (NoSuchFileException | AccessDeniedException e) {
+ throw e;
+ } catch (FileSystemException expected) {
+ // A busy pipe, no free instance yet: docker-java's loop below waits for one, and fails
+ // with this same exception if none frees up within the timeout.
+ }
+ super.connect(endpoint, timeout);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClient.java b/src/main/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClient.java
index 0b7fd8d92f..fdd46935da 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClient.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClient.java
@@ -166,7 +166,7 @@ public final class FlociDockerHttpClient implements DockerHttpClient {
return UnixDomainSocket.connect(path);
}
if ("npipe".equalsIgnoreCase(scheme)) {
- return new NamedPipeSocket(path);
+ return new FailFastNamedPipeSocket(path);
}
return socksProxy == null ? new Socket() : new Socket(socksProxy);
},
@@ -214,6 +214,14 @@ public final class FlociDockerHttpClient implements DockerHttpClient {
return new FlociResponse(httpRequest, response, ttyExec && response.getCode() == 200);
} catch (IOException e) {
throw new RuntimeException(e);
+ } catch (LinkageError e) {
+ // docker-java's named-pipe socket loads JNA when the pipe will not open. A JNA that
+ // cannot load (no native dispatch library for this platform) throws an Error, which
+ // the callers' catch (Exception) blocks would not stop, and one thrown during startup
+ // took down the whole emulator. As an exception it fails this one Docker call, the
+ // same way an unreachable daemon does.
+ throw new IllegalStateException("Docker's " + host.getSchemeName()
+ + " transport could not load its native library: " + e, e);
}
}
diff --git a/src/main/resources/META-INF/native-image/io.github.hectorvent/floci/reachability-metadata.json b/src/main/resources/META-INF/native-image/io.github.hectorvent/floci/reachability-metadata.json
new file mode 100644
index 0000000000..6025e016e6
--- /dev/null
+++ b/src/main/resources/META-INF/native-image/io.github.hectorvent/floci/reachability-metadata.json
@@ -0,0 +1,14 @@
+{
+ "reflection": [
+ {
+ "condition": {
+ "typeReached": "com.github.dockerjava.transport.NamedPipeSocket$Kernel32"
+ },
+ "type": {
+ "proxy": [
+ "com.github.dockerjava.transport.NamedPipeSocket$Kernel32"
+ ]
+ }
+ }
+ ]
+}
diff --git a/src/main/resources/META-INF/native-image/net.java.dev.jna/jna/reachability-metadata.json b/src/main/resources/META-INF/native-image/net.java.dev.jna/jna/reachability-metadata.json
new file mode 100644
index 0000000000..45f6d4c6cb
--- /dev/null
+++ b/src/main/resources/META-INF/native-image/net.java.dev.jna/jna/reachability-metadata.json
@@ -0,0 +1,1264 @@
+{
+ "reflection" : [
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Callback",
+ "jniAccessible" : true
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.CallbackReference"
+ },
+ "type" : "com.sun.jna.CallbackProxy",
+ "methods" : [
+ {
+ "name" : "callback",
+ "parameterTypes" : [
+ "java.lang.Object[]"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.CallbackProxy",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "callback",
+ "parameterTypes" : [
+ "java.lang.Object[]"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.CallbackReference",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "getCallback",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "com.sun.jna.Pointer",
+ "boolean"
+ ]
+ },
+ {
+ "name" : "getFunctionPointer",
+ "parameterTypes" : [
+ "com.sun.jna.Callback",
+ "boolean"
+ ]
+ },
+ {
+ "name" : "getNativeString",
+ "parameterTypes" : [
+ "java.lang.Object",
+ "boolean"
+ ]
+ },
+ {
+ "name" : "initializeThread",
+ "parameterTypes" : [
+ "com.sun.jna.Callback",
+ "com.sun.jna.CallbackReference$AttachOptions"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.CallbackReference$AttachOptions",
+ "jniAccessible" : true
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.FromNativeConverter",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "nativeType",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.IntegerType",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "value"
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.JNIEnv",
+ "jniAccessible" : true
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Native",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "dispose",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "fromNative",
+ "parameterTypes" : [
+ "com.sun.jna.FromNativeConverter",
+ "java.lang.Object",
+ "java.lang.reflect.Method"
+ ]
+ },
+ {
+ "name" : "fromNative",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "java.lang.Object"
+ ]
+ },
+ {
+ "name" : "fromNative",
+ "parameterTypes" : [
+ "java.lang.reflect.Method",
+ "java.lang.Object"
+ ]
+ },
+ {
+ "name" : "nativeType",
+ "parameterTypes" : [
+ "java.lang.Class"
+ ]
+ },
+ {
+ "name" : "toNative",
+ "parameterTypes" : [
+ "com.sun.jna.ToNativeConverter",
+ "java.lang.Object"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Native$ffi_callback",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "invoke",
+ "parameterTypes" : [
+ "long",
+ "long",
+ "long"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.NativeLong",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.NativeMapped",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "toNative",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Pointer",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "peer"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "long"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.PointerType",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "pointer"
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Structure",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "memory"
+ },
+ {
+ "name" : "typeInfo"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "autoRead",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "autoWrite",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "getTypeInfo",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "newInstance",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "long"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Structure$ByValue",
+ "jniAccessible" : true
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Structure$FFIType",
+ "fields" : [
+ {
+ "name" : "alignment"
+ },
+ {
+ "name" : "elements"
+ },
+ {
+ "name" : "size"
+ },
+ {
+ "name" : "type"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Structure"
+ },
+ "type" : "com.sun.jna.Structure$FFIType",
+ "fields" : [
+ {
+ "name" : "size"
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Structure$FFIType"
+ },
+ "type" : "com.sun.jna.Structure$FFIType",
+ "fields" : [
+ {
+ "name" : "alignment"
+ },
+ {
+ "name" : "elements"
+ },
+ {
+ "name" : "size"
+ },
+ {
+ "name" : "type"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Structure$FFIType$FFITypes",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "ffi_type_double"
+ },
+ {
+ "name" : "ffi_type_float"
+ },
+ {
+ "name" : "ffi_type_longdouble"
+ },
+ {
+ "name" : "ffi_type_pointer"
+ },
+ {
+ "name" : "ffi_type_sint16"
+ },
+ {
+ "name" : "ffi_type_sint32"
+ },
+ {
+ "name" : "ffi_type_sint64"
+ },
+ {
+ "name" : "ffi_type_sint8"
+ },
+ {
+ "name" : "ffi_type_uint16"
+ },
+ {
+ "name" : "ffi_type_uint32"
+ },
+ {
+ "name" : "ffi_type_uint64"
+ },
+ {
+ "name" : "ffi_type_uint8"
+ },
+ {
+ "name" : "ffi_type_void"
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.Structure$FFIType$size_t",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Structure"
+ },
+ "type" : "com.sun.jna.Structure$FFIType$size_t",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Structure$FFIType"
+ },
+ "type" : "com.sun.jna.Structure$FFIType$size_t",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Union"
+ },
+ "type" : "com.sun.jna.Union"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.WString",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "java.lang.String"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.ByteByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.DoubleByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.FloatByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.IntByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.LongByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.NativeLongByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.PointerByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "com.sun.jna.ptr.ShortByReference",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Boolean",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "boolean"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Byte",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "byte"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Character",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "char"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Class",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "getComponentType",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native$4"
+ },
+ "type" : "java.lang.ClassLoader"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Double",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "double"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Float",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "float"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Integer",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "int"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Long",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "long"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Library$Handler"
+ },
+ "type" : "java.lang.Object",
+ "methods" : [
+ {
+ "name" : "equals",
+ "parameterTypes" : [
+ "java.lang.Object"
+ ]
+ },
+ {
+ "name" : "hashCode",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "toString",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Object",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "toString",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Short",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ },
+ {
+ "name" : "value"
+ }
+ ],
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "short"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.String",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "byte[]"
+ ]
+ },
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "byte[]",
+ "java.lang.String"
+ ]
+ },
+ {
+ "name" : "getBytes",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "getBytes",
+ "parameterTypes" : [
+ "java.lang.String"
+ ]
+ },
+ {
+ "name" : "toCharArray",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Structure$FFIType"
+ },
+ "type" : "java.lang.String"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.System",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "getProperty",
+ "parameterTypes" : [
+ "java.lang.String"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.NativeLibrary"
+ },
+ "type" : "java.lang.Throwable",
+ "methods" : [
+ {
+ "name" : "addSuppressed",
+ "parameterTypes" : [
+ "java.lang.Throwable"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.UnsatisfiedLinkError",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "java.lang.String"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.Void",
+ "jniAccessible" : true,
+ "fields" : [
+ {
+ "name" : "TYPE"
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.internal.ReflectionUtils"
+ },
+ "type" : "java.lang.invoke.MethodHandle",
+ "methods" : [
+ {
+ "name" : "bindTo",
+ "parameterTypes" : [
+ "java.lang.Object"
+ ]
+ },
+ {
+ "name" : "invokeWithArguments",
+ "parameterTypes" : [
+ "java.lang.Object[]"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.internal.ReflectionUtils"
+ },
+ "type" : "java.lang.invoke.MethodHandles",
+ "methods" : [
+ {
+ "name" : "lookup",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "privateLookupIn",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "java.lang.invoke.MethodHandles$Lookup"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.internal.ReflectionUtils"
+ },
+ "type" : "java.lang.invoke.MethodHandles$Lookup",
+ "methods" : [
+ {
+ "name" : "findSpecial",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "java.lang.String",
+ "java.lang.invoke.MethodType",
+ "java.lang.Class"
+ ]
+ },
+ {
+ "name" : "in",
+ "parameterTypes" : [
+ "java.lang.Class"
+ ]
+ },
+ {
+ "name" : "unreflectSpecial",
+ "parameterTypes" : [
+ "java.lang.reflect.Method",
+ "java.lang.Class"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.internal.ReflectionUtils"
+ },
+ "type" : "java.lang.invoke.MethodType",
+ "methods" : [
+ {
+ "name" : "methodType",
+ "parameterTypes" : [
+ "java.lang.Class",
+ "java.lang.Class[]"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.lang.reflect.Method",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "getParameterTypes",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "getReturnType",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.VarArgsChecker"
+ },
+ "type" : "java.lang.reflect.Method",
+ "methods" : [
+ {
+ "name" : "isVarArgs",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.internal.ReflectionUtils"
+ },
+ "type" : "java.lang.reflect.Method",
+ "methods" : [
+ {
+ "name" : "isDefault",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.Buffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "position",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Platform"
+ },
+ "type" : "java.nio.Buffer"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.ByteBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.CharBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.DoubleBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.FloatBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.IntBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.LongBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.nio.ShortBuffer",
+ "jniAccessible" : true,
+ "methods" : [
+ {
+ "name" : "array",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "arrayOffset",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "java.security.SecureRandomParameters"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "long"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "sun.awt.X11.XErrorHandlerUtil",
+ "jniAccessible" : true
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "sun.security.provider.NativePRNG",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ },
+ {
+ "name" : "",
+ "parameterTypes" : [
+ "java.security.SecureRandomParameters"
+ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "type" : "sun.security.provider.SHA",
+ "methods" : [
+ {
+ "name" : "",
+ "parameterTypes" : [ ]
+ }
+ ]
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.CallbackReference"
+ },
+ "type" : {
+ "lambda" : {
+ "declaringClass" : "net_java_dev_jna.jna.CallbackAndUtilityCoverageTest",
+ "interfaces" : [
+ "net_java_dev_jna.jna.CallbackAndUtilityCoverageTest$Adder"
+ ]
+ }
+ }
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.CallbackReference"
+ },
+ "type" : {
+ "lambda" : {
+ "declaringClass" : "net_java_dev_jna.jna.CallbackAndUtilityCoverageTest",
+ "interfaces" : [
+ "net_java_dev_jna.jna.CallbackAndUtilityCoverageTest$StructureCallback"
+ ]
+ }
+ }
+ }
+ ],
+ "resources" : [
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "glob" : "com/sun/jna/darwin-aarch64/libjnidispatch.jnilib"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "glob" : "com/sun/jna/darwin-x86-64/libjnidispatch.jnilib"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "glob" : "com/sun/jna/linux-aarch64/libjnidispatch.so"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "glob" : "com/sun/jna/linux-x86-64/libjnidispatch.so"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.Native"
+ },
+ "glob" : "com/sun/jna/win32-x86-64/jnidispatch.dll"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.NativeLibrary"
+ },
+ "glob" : "libjnaCoverage94589515742070.so"
+ },
+ {
+ "condition" : {
+ "typeReached" : "com.sun.jna.NativeLibrary"
+ },
+ "glob" : "linux-x86-64/libjnaCoverage94589515742070.so"
+ }
+ ]
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 1e816665b2..860ad39a0d 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -134,6 +134,12 @@ quarkus:
additional-build-args:
- --enable-url-protocols=http,https
- --initialize-at-run-time=io.vertx.ext.mail.impl.sasl.NTLMEngineImpl
+ # JNA, which docker-java's named-pipe socket loads on Windows, binds its native dispatch
+ # library in Native's static initializer. Initialized at build time (the Quarkus default),
+ # that library loads into the builder and never into the binary, so every JNA call fails
+ # with UnsatisfiedLinkError on Native.open. The JNI and proxy metadata JNA needs at run time
+ # is under META-INF/native-image/net.java.dev.jna and META-INF/native-image/io.github.hectorvent.
+ - --initialize-at-run-time=com.sun.jna
- --initialize-at-run-time=com.github.dockerjava.transport.NamedPipeSocket$Kernel32
- --initialize-at-run-time=io.github.hectorvent.floci.services.acm.AcmService
- --initialize-at-run-time=io.github.hectorvent.floci.services.acm.CertificateGenerator
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/docker/DockerRetryTest.java b/src/test/java/io/github/hectorvent/floci/core/common/docker/DockerRetryTest.java
index 85fee89401..a5b90a999f 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/docker/DockerRetryTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/docker/DockerRetryTest.java
@@ -8,6 +8,8 @@ import java.io.InterruptedIOException;
import java.net.BindException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.NoSuchFileException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -196,4 +198,14 @@ class DockerRetryTest {
assertFalse(DockerRetry.isTransientIo(
new IOException("Broken pipe", new SocketException("PERMISSION DENIED"))));
}
+
+ @Test
+ void isTransientIo_missingOrDeniedNamedPipe_isNotTransient() {
+ // Windows without Docker running: the pipe is absent and its exception message is only the
+ // pipe's name, so the message match above cannot see it. Each retry cost a 30 s connect.
+ assertFalse(DockerRetry.isTransientIo(new NoSuchFileException("\\\\.\\pipe\\docker_engine")));
+ assertFalse(DockerRetry.isTransientIo(
+ new RuntimeException(new NoSuchFileException("\\\\.\\pipe\\docker_engine"))));
+ assertFalse(DockerRetry.isTransientIo(new AccessDeniedException("\\\\.\\pipe\\docker_engine")));
+ }
}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClientTest.java b/src/test/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClientTest.java
index a65194bb34..189530ae90 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClientTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/docker/FlociDockerHttpClientTest.java
@@ -5,6 +5,8 @@ import org.apache.hc.core5.http.ConnectionRequestTimeoutException;
import org.apache.hc.core5.util.TimeValue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
@@ -18,6 +20,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
@@ -96,6 +99,58 @@ class FlociDockerHttpClientTest {
}
}
+ // Catches: a named-pipe host whose JNA cannot load throwing an Error out of execute(), past
+ // every caller's catch (Exception); at startup that took down the Windows binary. A directory
+ // stands in for a busy pipe: it exists but cannot be opened for writing, so the open fails with
+ // a plain FileSystemException and docker-java's wait loop reaches for Kernel32, which cannot
+ // load off Windows. Not on Windows, where Kernel32 loads and a directory is access-denied.
+ @Test
+ @DisabledOnOs(OS.WINDOWS)
+ @Timeout(30)
+ void aNamedPipeTransportThatCannotLoadItsNativeLibraryFailsTheCallWithAnException(@TempDir Path dir)
+ throws Exception {
+ try (FlociDockerHttpClient client = new FlociDockerHttpClient.Builder()
+ .dockerHost(URI.create("npipe://" + dir.toUri().getPath()))
+ .build()) {
+ for (int attempt = 1; attempt <= 2; attempt++) {
+ IllegalStateException failure = assertThrows(IllegalStateException.class,
+ () -> client.execute(get("/_ping")));
+ assertTrue(failure.getCause() instanceof LinkageError,
+ "attempt " + attempt + " should wrap the LinkageError, got " + failure.getCause());
+ }
+ }
+ }
+
+ // Catches: a named pipe that does not exist (Windows without Docker running) spending the whole
+ // connect timeout in docker-java's wait loop, and DockerRetry retrying it, so every Docker call
+ // took 30 s per attempt and the binary never answered its health check. Not on Windows, where
+ // a temp-directory path is not a pipe name.
+ @Test
+ @DisabledOnOs(OS.WINDOWS)
+ @Timeout(10)
+ void aNamedPipeThatDoesNotExistFailsAtOnceAndIsNotRetried(@TempDir Path dir) throws Exception {
+ try (FlociDockerHttpClient client = new FlociDockerHttpClient.Builder()
+ .dockerHost(URI.create("npipe://" + dir.resolve("no_such_pipe").toUri().getPath()))
+ .connectionTimeout(Duration.ofSeconds(30))
+ .build()) {
+ long start = System.nanoTime();
+ RuntimeException failure = assertThrows(RuntimeException.class, () -> client.execute(get("/_ping")));
+ long elapsedMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
+ assertTrue(elapsedMs < 5_000, "a missing pipe should fail at once, took " + elapsedMs + " ms");
+ assertTrue(hasCause(failure, NoSuchFileException.class), "expected a NoSuchFileException, got " + failure);
+ assertFalse(DockerRetry.isTransientIo(failure), "a missing pipe must not be retried");
+ }
+ }
+
+ private static boolean hasCause(Throwable t, Class extends Throwable> type) {
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ if (type.isInstance(c)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static DockerHttpClient.Request get(String path) {
return DockerHttpClient.Request.builder().method(DockerHttpClient.Request.Method.GET).path(path).build();
}