From 898d21f988d23b38588b7462a526ea4fa8df67a9 Mon Sep 17 00:00:00 2001 From: Jsebayhi Date: Mon, 27 Nov 2023 12:14:09 +0100 Subject: [PATCH] Update ProbeService.java readiness to report ready only if the application is running (#133) In kubernetes, readiness are used to determine if a loadbalancer can forward request to a pod. If a pod declare that he is ready, he will receive traffic. The readiness for a kafka stream application is useful if we want to deploy a rest endpoint on top of it like an interactive query. (https://docs.confluent.io/platform/current/streams/developer-guide/interactive-queries.html) In such a case, we do not want a pod to pretend that it is ready if it is rebalancing, since it is potentially transferring state stores and therefore a potentially inconsistent state. --- .../java/com/michelin/kstreamplify/services/ProbeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kstreamplify-core/src/main/java/com/michelin/kstreamplify/services/ProbeService.java b/kstreamplify-core/src/main/java/com/michelin/kstreamplify/services/ProbeService.java index a52111f7..283a143e 100644 --- a/kstreamplify-core/src/main/java/com/michelin/kstreamplify/services/ProbeService.java +++ b/kstreamplify-core/src/main/java/com/michelin/kstreamplify/services/ProbeService.java @@ -49,7 +49,7 @@ public static RestServiceResponse readinessProbe( } } - return kafkaStreamsInitializer.getKafkaStreams().state().isRunningOrRebalancing() + return kafkaStreamsInitializer.getKafkaStreams().state().equals(KafkaStreams.State.RUNNING) ? RestServiceResponse.builder().status(HttpURLConnection.HTTP_OK).build() : RestServiceResponse.builder().status(HttpURLConnection.HTTP_UNAVAILABLE) .build();