mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
fix(lifecycle): run start/ready hooks when FLOCI_PORT is non-default (#2439)
onHttpStart compared the HTTP server port against a hardcoded 4566, but
Quarkus actually listens on floci.port (quarkus.http.port: ${floci.port}).
With any non-default FLOCI_PORT the guard never matched, so start/ready
hooks never ran and /_floci/init stayed stuck at boot:true forever while
/_floci/health returned 200.
Compare against config.port() instead. TLS mode is unchanged: TlsConfigSource
pins the HTTP backend to 4510 regardless of floci.port.
Fixes #2437
Co-authored-by: anmolxlight <anmolxlight@users.noreply.github.com>
This commit is contained in:
1 parent
39ed7712a7
commit
ba97c084eb
2 files changed
+22
-2
No files matched your search
@@ -49,7 +49,6 @@ import java.util.Optional;
|
||||
public class EmulatorLifecycle {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(EmulatorLifecycle.class);
|
||||
private static final int HTTP_PORT = 4566;
|
||||
private static final int TLS_HTTP_BACKEND_PORT = 4510;
|
||||
|
||||
@ConfigProperty(name = "quarkus.application.version", defaultValue = "")
|
||||
@@ -211,7 +210,11 @@ public class EmulatorLifecycle {
|
||||
}
|
||||
|
||||
void onHttpStart(@ObservesAsync HttpServerStart event) {
|
||||
int expectedPort = config.tls().enabled() ? TLS_HTTP_BACKEND_PORT : HTTP_PORT;
|
||||
// Non-TLS: Quarkus listens on floci.port (quarkus.http.port: ${floci.port} in
|
||||
// application.yml). TLS mode: TlsConfigSource pins the HTTP backend to 4510 and the
|
||||
// public port is served by TlsProxyServer. Comparing against a hardcoded 4566 here
|
||||
// made start/ready hooks never run when FLOCI_PORT was non-default (#2437).
|
||||
int expectedPort = config.tls().enabled() ? TLS_HTTP_BACKEND_PORT : config.port();
|
||||
if (event.options().getPort() != expectedPort) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ class EmulatorLifecycleTest {
|
||||
Mockito.lenient().when(elbv2ServiceConfig.enabled()).thenReturn(false);
|
||||
Mockito.lenient().when(config.tls()).thenReturn(tlsConfig);
|
||||
Mockito.lenient().when(tlsConfig.enabled()).thenReturn(false);
|
||||
Mockito.lenient().when(config.port()).thenReturn(4566);
|
||||
|
||||
emulatorLifecycle = new EmulatorLifecycle(
|
||||
storageFactory, serviceRegistry, config,
|
||||
@@ -254,6 +255,22 @@ class EmulatorLifecycleTest {
|
||||
verify(initLifecycleState).markStartCompleted();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("onHttpStart on a non-default floci.port (non-TLS) triggers hook execution (#2437)")
|
||||
void onHttpStart_nonTls_triggersHooksOnCustomPort() throws IOException, InterruptedException {
|
||||
Mockito.lenient().when(config.port()).thenReturn(4577);
|
||||
when(tlsConfig.enabled()).thenReturn(false);
|
||||
when(initializationHooksRunner.hasHooks(InitializationHook.START)).thenReturn(true);
|
||||
when(initializationHooksRunner.hasHooks(InitializationHook.READY)).thenReturn(true);
|
||||
|
||||
emulatorLifecycle.onHttpStart(new HttpServerStart(new HttpServerOptions().setPort(4577)));
|
||||
|
||||
verify(initializationHooksRunner).run(InitializationHook.START);
|
||||
verify(initializationHooksRunner).run(InitializationHook.READY);
|
||||
verify(initLifecycleState).markStartCompleted();
|
||||
verify(initLifecycleState).markReadyCompleted();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("onHttpStart on wrong port (non-TLS) is ignored")
|
||||
void onHttpStart_nonTls_ignoresWrongPort() throws IOException, InterruptedException {
|
||||
|
||||
Reference in new issue
Block a user