mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
fix: gcp health check fix
This commit is contained in:
10 files changed
+50
-16
No files matched your search
@@ -7,6 +7,12 @@ This project uses [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.4] — 2026-06-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- `floci gcp wait` / `status` / `version` / `services` / `doctor` timed out or reported the server unreachable even when the floci-gcp container was healthy — the CLI probed the AWS/Azure control path `/_floci/health`, which the GCP server routes into its GCS service (`object not found bucket=_floci name=health`). The GCP control plane lives under `/_floci-gcp`; `FlociHttpClient` now takes a configurable control-plane prefix and the `floci gcp` commands use `/_floci-gcp`
|
||||
|
||||
## [0.1.3] — 2026-06-02
|
||||
|
||||
### Added
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>io.floci</groupId>
|
||||
<artifactId>floci-cli</artifactId>
|
||||
<version>0.1.3</version>
|
||||
<version>0.1.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Floci CLI</name>
|
||||
|
||||
@@ -10,6 +10,9 @@ import java.net.URI;
|
||||
|
||||
public class GcpGlobalOptions {
|
||||
|
||||
/** Control-plane path prefix exposed by the floci-gcp server (differs from AWS/Azure's {@code /_floci}). */
|
||||
public static final String CONTROL_PREFIX = "/_floci-gcp";
|
||||
|
||||
@Option(names = {"--endpoint"},
|
||||
description = "Floci GCP server endpoint URL",
|
||||
defaultValue = "${FLOCI_GCP_ENDPOINT:-http://localhost:4588}",
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GcpDoctorCommand implements Callable<Integer> {
|
||||
checks.add(new ImagePresentCheck("floci/floci-gcp"));
|
||||
checks.add(new ImageVersionCheck("floci/floci-gcp"));
|
||||
checks.add(new ContainerRunningCheck());
|
||||
checks.add(new EndpointReachableCheck());
|
||||
checks.add(new EndpointReachableCheck(io.floci.cli.GcpGlobalOptions.CONTROL_PREFIX));
|
||||
ALL_CHECKS = List.copyOf(checks);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class GcpServicesCommand implements Callable<Integer> {
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint, GcpGlobalOptions.CONTROL_PREFIX);
|
||||
|
||||
List<String> services;
|
||||
try {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GcpStatusCommand implements Callable<Integer> {
|
||||
String serverVersion = "unavailable";
|
||||
String serverEdition = "";
|
||||
boolean reachable = false;
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, GcpGlobalOptions.CONTROL_PREFIX);
|
||||
try {
|
||||
var health = client.health();
|
||||
serverVersion = health.version();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class GcpVersionCommand implements Callable<Integer> {
|
||||
DockerClient docker = new DockerClient();
|
||||
String effectiveEndpoint = global.resolvedEndpoint(docker);
|
||||
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, GcpGlobalOptions.CONTROL_PREFIX);
|
||||
try {
|
||||
var info = client.info();
|
||||
serverVersion = info.version();
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GcpWaitCommand implements Callable<Integer> {
|
||||
Printer printer = global.printer();
|
||||
long timeoutMillis = WaitCommand.parseDuration(timeout);
|
||||
String effectiveEndpoint = global.resolvedEndpoint(new io.floci.cli.docker.DockerClient());
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, GcpGlobalOptions.CONTROL_PREFIX);
|
||||
Instant deadline = Instant.now().plusMillis(timeoutMillis);
|
||||
|
||||
while (Instant.now().isBefore(deadline)) {
|
||||
|
||||
@@ -6,9 +6,19 @@ import io.floci.cli.http.FlociHttpClient;
|
||||
|
||||
public class EndpointReachableCheck implements Check {
|
||||
|
||||
private final String controlPrefix;
|
||||
|
||||
public EndpointReachableCheck() {
|
||||
this(FlociHttpClient.DEFAULT_CONTROL_PREFIX);
|
||||
}
|
||||
|
||||
public EndpointReachableCheck(String controlPrefix) {
|
||||
this.controlPrefix = controlPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckResult run(String endpoint, String container) {
|
||||
FlociHttpClient client = new FlociHttpClient(endpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(endpoint, controlPrefix);
|
||||
if (client.isReachable()) {
|
||||
try {
|
||||
var health = client.health();
|
||||
@@ -19,7 +29,7 @@ public class EndpointReachableCheck implements Check {
|
||||
}
|
||||
}
|
||||
return CheckResult.fail("endpoint.reachable",
|
||||
"GET /_floci/health at " + endpoint + " did not return 200",
|
||||
"GET " + controlPrefix + "/health at " + endpoint + " did not return 200",
|
||||
"Is Floci running? Try 'floci start'.");
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,33 @@ public class FlociHttpClient {
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
/** Default control-plane path prefix used by the AWS and Azure emulators. */
|
||||
public static final String DEFAULT_CONTROL_PREFIX = "/_floci";
|
||||
|
||||
private final String endpoint;
|
||||
private final String controlPrefix;
|
||||
private final HttpClient http;
|
||||
|
||||
public FlociHttpClient(String endpoint) {
|
||||
this(endpoint, DEFAULT_CONTROL_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controlPrefix the control-plane path prefix exposed by the target server
|
||||
* (e.g. {@code /_floci} for AWS/Azure, {@code /_floci-gcp} for GCP).
|
||||
*/
|
||||
public FlociHttpClient(String endpoint, String controlPrefix) {
|
||||
this.endpoint = endpoint.endsWith("/") ? endpoint.substring(0, endpoint.length() - 1) : endpoint;
|
||||
this.controlPrefix = controlPrefix.endsWith("/")
|
||||
? controlPrefix.substring(0, controlPrefix.length() - 1)
|
||||
: controlPrefix;
|
||||
this.http = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(5))
|
||||
.build();
|
||||
}
|
||||
|
||||
public HealthInfo health() throws FlociException {
|
||||
JsonNode node = getJson("/_floci/health");
|
||||
JsonNode node = getJson(controlPrefix + "/health");
|
||||
return new HealthInfo(
|
||||
node.path("version").asText("unknown"),
|
||||
node.path("original_edition").asText(node.path("edition").asText("community")),
|
||||
@@ -44,14 +59,14 @@ public class FlociHttpClient {
|
||||
}
|
||||
|
||||
public ServerInfo info() throws FlociException {
|
||||
JsonNode node = getJson("/_floci/info");
|
||||
JsonNode node = getJson(controlPrefix + "/info");
|
||||
return new ServerInfo(
|
||||
node.path("version").asText("unknown"),
|
||||
node.path("original_edition").asText(node.path("edition").asText("community")));
|
||||
}
|
||||
|
||||
public InitState initState() throws FlociException {
|
||||
JsonNode node = getJson("/_floci/init");
|
||||
JsonNode node = getJson(controlPrefix + "/init");
|
||||
JsonNode completed = node.path("completed");
|
||||
return new InitState(
|
||||
completed.path("boot").asBoolean(),
|
||||
@@ -63,7 +78,7 @@ public class FlociHttpClient {
|
||||
public boolean isReachable() {
|
||||
try {
|
||||
HttpRequest req = HttpRequest.newBuilder()
|
||||
.uri(URI.create(endpoint + "/_floci/health"))
|
||||
.uri(URI.create(endpoint + controlPrefix + "/health"))
|
||||
.timeout(Duration.ofSeconds(3))
|
||||
.GET()
|
||||
.build();
|
||||
@@ -75,19 +90,19 @@ public class FlociHttpClient {
|
||||
}
|
||||
|
||||
public Map<String, Object> postSnapshot(String name) throws FlociException {
|
||||
return postJson("/_floci/snapshots/" + name, "{}");
|
||||
return postJson(controlPrefix + "/snapshots/" + name, "{}");
|
||||
}
|
||||
|
||||
public Map<String, Object> loadSnapshot(String name) throws FlociException {
|
||||
return postJson("/_floci/snapshots/" + name + "/load", "{}");
|
||||
return postJson(controlPrefix + "/snapshots/" + name + "/load", "{}");
|
||||
}
|
||||
|
||||
public JsonNode listSnapshots() throws FlociException {
|
||||
return getJson("/_floci/snapshots");
|
||||
return getJson(controlPrefix + "/snapshots");
|
||||
}
|
||||
|
||||
public void deleteSnapshot(String name) throws FlociException {
|
||||
deleteRequest("/_floci/snapshots/" + name);
|
||||
deleteRequest(controlPrefix + "/snapshots/" + name);
|
||||
}
|
||||
|
||||
private JsonNode getJson(String path) throws FlociException {
|
||||
|
||||
Reference in new issue
Block a user