mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(floci-ui): report real sidecar-start failures instead of always blaming the image (#1544)
Pressing 'Open Floci UI' under Podman (docker-socket compat) reports every failure as a missing image and tells the user to 'docker pull floci-ui' — even when the image is present. The real causes (an unreachable Docker/Podman socket, a port clash, a daemon error) are hidden, which is especially confusing on SELinux hosts where the bind-mounted socket connect fails with 'java.net.BindException: Permission denied'. Classify the failure in FlociUiManager.describeStartFailure: - only a genuinely unavailable image (NotFoundException / docker-java's 'Could not pull image: ...' wrapper) keeps the 'docker pull' guidance; - an unreachable runtime (SocketException/BindException/ConnectException) points at the socket mount and SELinux relabeling; - any other daemon error is surfaced as-is (e.g. 'address already in use'). Also fix the Podman docs: use ':z' (shared relabel) rather than ':Z' on the shared Podman API socket, note it applies to the UI sidecar, and mention the '--security-opt label=disable' fallback. Add unit tests for the four classifications.
This commit is contained in:
1 parent
7efb280dbc
commit
a6c6cf6de9
3 files changed
+122
-7
No files matched your search
@@ -9,11 +9,16 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.E
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
|
||||
import io.github.hectorvent.floci.core.common.docker.CurrentContainerNetworkResolver;
|
||||
import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
|
||||
import com.github.dockerjava.api.exception.DockerClientException;
|
||||
import com.github.dockerjava.api.exception.NotFoundException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.BindException;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -116,6 +121,53 @@ class FlociUiManagerTest {
|
||||
assertEquals(4500, newManager().resolveHostPort(null, 4500));
|
||||
}
|
||||
|
||||
@Test
|
||||
void startFailureFromMissingImageKeepsPullGuidance() {
|
||||
// A genuinely missing image (docker-java's pull-callback wrapper) — keep "docker pull".
|
||||
Exception e = new DockerClientException("Could not pull image: not found");
|
||||
|
||||
String msg = FlociUiManager.describeStartFailure("floci/floci-ui:latest", e);
|
||||
|
||||
assertTrue(msg.contains("docker pull floci/floci-ui:latest"),
|
||||
"missing-image failure should still suggest docker pull, was: " + msg);
|
||||
assertTrue(msg.contains("unavailable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void startFailureFromMissingImageNotFoundKeepsPullGuidance() {
|
||||
Exception e = new NotFoundException("no such image");
|
||||
|
||||
String msg = FlociUiManager.describeStartFailure("floci/floci-ui:latest", e);
|
||||
|
||||
assertTrue(msg.contains("docker pull floci/floci-ui:latest"), msg);
|
||||
}
|
||||
|
||||
@Test
|
||||
void startFailureFromUnreachableSocketDoesNotBlameImage() {
|
||||
// The Podman/SELinux symptom: docker-java's Apache transport wraps a denied
|
||||
// Unix-socket connect as RuntimeException -> BindException. Must NOT suggest a pull.
|
||||
Exception e = new RuntimeException(new BindException("Permission denied"));
|
||||
|
||||
String msg = FlociUiManager.describeStartFailure("floci/floci-ui:latest", e);
|
||||
|
||||
assertFalse(msg.contains("docker pull"),
|
||||
"socket-permission failure must not be reported as a missing image, was: " + msg);
|
||||
assertTrue(msg.contains("could not reach the container runtime"), msg);
|
||||
assertTrue(msg.contains("Permission denied"), msg);
|
||||
}
|
||||
|
||||
@Test
|
||||
void startFailureFromPortConflictDoesNotBlameImage() {
|
||||
// Daemon error (e.g. port already in use) — report it as-is, no pull guidance.
|
||||
Exception e = new RuntimeException(
|
||||
"Status 500: listen tcp :4500: bind: address already in use");
|
||||
|
||||
String msg = FlociUiManager.describeStartFailure("floci/floci-ui:latest", e);
|
||||
|
||||
assertFalse(msg.contains("docker pull"), msg);
|
||||
assertTrue(msg.contains("address already in use"), msg);
|
||||
}
|
||||
|
||||
@Test
|
||||
void usesHttpsSchemeWhenTlsEnabled() {
|
||||
when(containerDetector.isRunningInContainer()).thenReturn(false);
|
||||
|
||||
Reference in new issue
Block a user