Skip to content

Commit

Permalink
eclipse-jkube#579 - Fixed health paths
Browse files Browse the repository at this point in the history
Signed-off-by: dloiacono <[email protected]>
  • Loading branch information
domenico.loiacono authored and dloiacono committed Feb 22, 2021
1 parent d8385d1 commit 4db56e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand All @@ -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;
Expand All @@ -52,23 +56,25 @@ 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;
}

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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4db56e3

Please sign in to comment.