From 6f4bd85f71a4196e6824ee7679fb2cf3080643cd Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Fri, 16 Aug 2024 14:43:07 -0600 Subject: [PATCH] Addressed PR review comments Signed-off-by: Alfredo Gutierrez --- .../templates/deployment.yaml | 6 ++--- charts/hedera-block-node/values.yaml | 4 ++-- .../block/server/health/HealthService.java | 7 +++--- .../server/health/HealthServiceImpl.java | 23 +++++++++++++++---- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/charts/hedera-block-node/templates/deployment.yaml b/charts/hedera-block-node/templates/deployment.yaml index 222f8c41..03fc4512 100644 --- a/charts/hedera-block-node/templates/deployment.yaml +++ b/charts/hedera-block-node/templates/deployment.yaml @@ -45,9 +45,9 @@ spec: path: {{ .Values.blockNode.health.liveness.endpoint }} port: {{ .Values.service.port }} readinessProbe: - httpGet: - path: {{ .Values.blockNode.health.readiness.endpoint }} - port: {{ .Values.service.port }} + httpGet: + path: {{ .Values.blockNode.health.readiness.endpoint }} + port: {{ .Values.service.port }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/hedera-block-node/values.yaml b/charts/hedera-block-node/values.yaml index 35432081..68b8d40b 100644 --- a/charts/hedera-block-node/values.yaml +++ b/charts/hedera-block-node/values.yaml @@ -84,6 +84,6 @@ blockNode: PRIVATE_KEY: "fake_private_key" health: readiness: - endpoint: "/health/readiness" + endpoint: "/healthz/readiness" liveness: - endpoint: "/health/liveness" + endpoint: "/healthz/liveness" diff --git a/server/src/main/java/com/hedera/block/server/health/HealthService.java b/server/src/main/java/com/hedera/block/server/health/HealthService.java index 73e38c23..533dff8d 100644 --- a/server/src/main/java/com/hedera/block/server/health/HealthService.java +++ b/server/src/main/java/com/hedera/block/server/health/HealthService.java @@ -16,6 +16,7 @@ package com.hedera.block.server.health; +import edu.umd.cs.findbugs.annotations.NonNull; import io.helidon.webserver.http.HttpRules; import io.helidon.webserver.http.HttpService; import io.helidon.webserver.http.ServerRequest; @@ -36,7 +37,7 @@ public interface HealthService extends HttpService { * @param httpRules is used to configure the health endpoints routes */ @Override - void routing(HttpRules httpRules); + void routing(@NonNull final HttpRules httpRules); /** * Handles the request for liveness endpoint, that it most be defined on routing implementation. @@ -44,7 +45,7 @@ public interface HealthService extends HttpService { * @param req the server request * @param res the server response */ - void handleLiveness(ServerRequest req, ServerResponse res); + void handleLiveness(@NonNull final ServerRequest req, @NonNull final ServerResponse res); /** * Handles the request for readiness endpoint, that it most be defined on routing @@ -53,5 +54,5 @@ public interface HealthService extends HttpService { * @param req the server request * @param res the server response */ - void handleReadiness(ServerRequest req, ServerResponse res); + void handleReadiness(@NonNull final ServerRequest req, @NonNull final ServerResponse res); } diff --git a/server/src/main/java/com/hedera/block/server/health/HealthServiceImpl.java b/server/src/main/java/com/hedera/block/server/health/HealthServiceImpl.java index f6164b24..59ec93d5 100644 --- a/server/src/main/java/com/hedera/block/server/health/HealthServiceImpl.java +++ b/server/src/main/java/com/hedera/block/server/health/HealthServiceImpl.java @@ -41,7 +41,7 @@ public HealthServiceImpl(@NonNull ServiceStatus serviceStatus) { @Override public String getHealthRootPath() { - return "/health"; + return "/healthz"; } /** @@ -50,14 +50,21 @@ public String getHealthRootPath() { * @param httpRules is used to configure the health endpoints routes */ @Override - public void routing(HttpRules httpRules) { + public void routing(@NonNull final HttpRules httpRules) { httpRules .get(LIVENESS_PATH, this::handleLiveness) .get(READINESS_PATH, this::handleReadiness); } + /** + * Handles the request for liveness endpoint, that it most be defined on routing implementation. + * + * @param req the server request + * @param res the server response + */ @Override - public void handleLiveness(ServerRequest req, ServerResponse res) { + public final void handleLiveness( + @NonNull final ServerRequest req, @NonNull final ServerResponse res) { if (serviceStatus.isRunning()) { res.status(200).send("OK"); } else { @@ -65,8 +72,16 @@ public void handleLiveness(ServerRequest req, ServerResponse res) { } } + /** + * Handles the request for readiness endpoint, that it most be defined on routing + * implementation. + * + * @param req the server request + * @param res the server response + */ @Override - public void handleReadiness(ServerRequest req, ServerResponse res) { + public final void handleReadiness( + @NonNull final ServerRequest req, @NonNull final ServerResponse res) { if (serviceStatus.isRunning()) { res.status(200).send("OK"); } else {