From 4db56e3d733985ddae74d051c73f89801b003626 Mon Sep 17 00:00:00 2001 From: "domenico.loiacono" Date: Wed, 17 Feb 2021 18:10:16 +0100 Subject: [PATCH] #579 - Fixed health paths Signed-off-by: dloiacono --- CHANGELOG.md | 1 + .../enricher/QuarkusHealthCheckEnricher.java | 16 +++++++++++----- .../enricher/QuarkusHealthCheckEnricherTest.java | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 105c79ee3c..e579b7ec5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Usage: ./scripts/extract-changelog-for-version.sh 1.3.37 5 ``` ### 1.1.0 (2021-01-28) +* Fix #579: Fixed quarkus health paths * Fix #455: Use OpenShiftServer with JUnit rule instead of directly instantiating the OpenShiftMockServer * Fix #467: Upgrade assertj-core to 3.18.0 * Fix #460: Added a Quickstart for implementing and using a Custom Enricher based on Eclipse JKube Kit Enricher API diff --git a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java index 76a2f87e5b..e4e0c8d741 100644 --- a/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java +++ b/jkube-kit/jkube-kit-quarkus/src/main/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricher.java @@ -15,6 +15,7 @@ import io.fabric8.kubernetes.api.model.Probe; import io.fabric8.kubernetes.api.model.ProbeBuilder; +import java.nio.file.Paths; import lombok.AllArgsConstructor; import lombok.Getter; import org.eclipse.jkube.kit.common.Configs; @@ -29,6 +30,9 @@ */ public class QuarkusHealthCheckEnricher extends AbstractHealthCheckEnricher { + private static final String READY_SUBPATH = "ready"; + private static final String LIVE_SUBPATH = "live"; + public QuarkusHealthCheckEnricher(JKubeEnricherContext buildContext) { super(buildContext, "jkube-healthcheck-quarkus"); } @@ -42,7 +46,7 @@ private enum Config implements Configs.Config { SUCCESS_THRESHOLD("successThreshold", "1"), LIVENESS_INITIAL_DELAY("livenessInitialDelay", null), READINESS_INTIAL_DELAY("readinessIntialDelay", null), - PATH("path", "/health"); + HEALTH_PATH("path", "health"); @Getter protected String key; @@ -52,15 +56,17 @@ private enum Config implements Configs.Config { @Override protected Probe getReadinessProbe() { - return discoverQuarkusHealthCheck(asInteger(getConfig(Config.READINESS_INTIAL_DELAY, "5"))); + return discoverQuarkusHealthCheck(asInteger(getConfig(Config.READINESS_INTIAL_DELAY, "5")), + READY_SUBPATH); } @Override protected Probe getLivenessProbe() { - return discoverQuarkusHealthCheck(asInteger(getConfig(Config.LIVENESS_INITIAL_DELAY, "10"))); + return discoverQuarkusHealthCheck(asInteger(getConfig(Config.LIVENESS_INITIAL_DELAY, "10")), + LIVE_SUBPATH); } - private Probe discoverQuarkusHealthCheck(int initialDelay) { + private Probe discoverQuarkusHealthCheck(int initialDelay, String subPath) { if (!getContext().hasDependency("io.quarkus", "quarkus-smallrye-health")) { return null; } @@ -68,7 +74,7 @@ private Probe discoverQuarkusHealthCheck(int initialDelay) { return new ProbeBuilder() .withNewHttpGet() .withNewPort(asInteger(getConfig(Config.PORT))) - .withPath(getConfig(Config.PATH)) + .withPath(Paths.get("/", getConfig(Config.HEALTH_PATH), subPath).toString()) .withScheme(getConfig(Config.SCHEME)) .endHttpGet() .withFailureThreshold(asInteger(getConfig(Config.FAILURE_THRESHOLD))) diff --git a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java index 7dc3ff02dd..8b016bd60b 100644 --- a/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java +++ b/jkube-kit/jkube-kit-quarkus/src/test/java/org/eclipse/jkube/quarkus/enricher/QuarkusHealthCheckEnricherTest.java @@ -83,7 +83,7 @@ public void createWithDefaultsInKubernetes() { .extracting( "livenessProbe.httpGet.scheme", "livenessProbe.httpGet.path", "readinessProbe.httpGet.scheme", "readinessProbe.httpGet.path") - .containsExactly(tuple("HTTP", "/health", "HTTP", "/health")); + .containsExactly(tuple("HTTP", "/health/live", "HTTP", "/health/ready")); } @Test @@ -102,7 +102,7 @@ public void createWithCustomPathInKubernetes() { .extracting( "livenessProbe.httpGet.scheme", "livenessProbe.httpGet.path", "readinessProbe.httpGet.scheme", "readinessProbe.httpGet.path") - .containsExactly(tuple("HTTP", "/my-custom-path", "HTTP", "/my-custom-path")); + .containsExactly(tuple("HTTP", "/my-custom-path/live", "HTTP", "/my-custom-path/ready")); } @Test