mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 17:33:03 -05:00
fix(floci-ui): resolve readiness probe URL from container endpoint (#1471)
* fix(floci-ui): resolve readiness probe URL from container endpoint Resolve the floci-ui readiness probe URL once at start/adopt time from the sidecar's resolved EndpointInfo instead of branching on container detection each probe. EndpointInfo already returns a Floci-reachable address — localhost:hostPort natively, or the sidecar's container IP on the shared Docker network when Floci runs in a container, where the published host port is unreachable from inside. * fix(floci-ui): set hostPort from bound endpoint natively, keep configured port in container Address PR review: EndpointInfo.port() is the real host binding only in native mode (and reflects dynamic port=0 allocation there). In container mode it is the sidecar's internal port (4500), so the configured published port stays authoritative for the browser redirect. Extract resolveHostPort() and use it in both ensureStarted() and adoptExisting().
This commit is contained in:
1 parent
0870f993a4
commit
9253ee82b0
2 files changed
+99
-9
No files matched your search
@@ -5,6 +5,7 @@ import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerBuilder;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
|
||||
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;
|
||||
@@ -67,6 +68,54 @@ class FlociUiManagerTest {
|
||||
assertEquals("http://host.docker.internal:4566", newManager().resolveFlociEndpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
void probeUsesSidecarContainerIpWhenContainerized() {
|
||||
// In a container the published host port is not reachable via localhost; the
|
||||
// probe must target the sidecar's container IP on the shared Docker network.
|
||||
EndpointInfo endpoint = new EndpointInfo("10.88.0.20", 4500);
|
||||
|
||||
assertEquals("http://10.88.0.20:4500/", newManager().resolveProbeUrl(endpoint, 4500));
|
||||
}
|
||||
|
||||
@Test
|
||||
void probeUsesLocalhostHostPortNatively() {
|
||||
EndpointInfo endpoint = new EndpointInfo("localhost", 4500);
|
||||
|
||||
assertEquals("http://localhost:4500/", newManager().resolveProbeUrl(endpoint, 4500));
|
||||
}
|
||||
|
||||
@Test
|
||||
void probeFallsBackToLocalhostWhenEndpointMissing() {
|
||||
assertEquals("http://localhost:4500/", newManager().resolveProbeUrl(null, 4500));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostPortUsesBoundEndpointPortNatively() {
|
||||
// Native mode: EndpointInfo carries the actual bound host port, which may differ
|
||||
// from the requested port when dynamic allocation (port=0) is used.
|
||||
when(containerDetector.isRunningInContainer()).thenReturn(false);
|
||||
EndpointInfo endpoint = new EndpointInfo("localhost", 49160);
|
||||
|
||||
assertEquals(49160, newManager().resolveHostPort(endpoint, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostPortKeepsConfiguredPublishedPortWhenContainerized() {
|
||||
// Container mode: EndpointInfo carries the sidecar's internal port (4500), not the
|
||||
// host binding, so the configured published port must win for the browser redirect.
|
||||
when(containerDetector.isRunningInContainer()).thenReturn(true);
|
||||
EndpointInfo endpoint = new EndpointInfo("10.88.0.20", 4500);
|
||||
|
||||
assertEquals(8080, newManager().resolveHostPort(endpoint, 8080));
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostPortFallsBackToConfiguredWhenEndpointMissing() {
|
||||
when(containerDetector.isRunningInContainer()).thenReturn(false);
|
||||
|
||||
assertEquals(4500, newManager().resolveHostPort(null, 4500));
|
||||
}
|
||||
|
||||
@Test
|
||||
void usesHttpsSchemeWhenTlsEnabled() {
|
||||
when(containerDetector.isRunningInContainer()).thenReturn(false);
|
||||
|
||||
Reference in new issue
Block a user