From 80111fe3c4c1e2e145485c2f2a833bdaabb3a680 Mon Sep 17 00:00:00 2001 From: "aravind.est" Date: Mon, 6 Mar 2023 16:29:58 +0000 Subject: Add log message when kserve setup is unavailable and improve coverage Add log message when kserve setup is unavailable. Improve code coverage. Issue-ID: POLICY-4525 Signed-off-by: aravind.est Change-Id: If92fc38ceb8e3427e4b2c6045d2fd3ffcc106198 --- .../kserve/handler/AutomationCompositionElementHandler.java | 5 +++-- .../acm/participant/kserve/k8s/InferenceServiceValidator.java | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'participant/participant-impl/participant-impl-kserve/src/main/java') diff --git a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java index 07fbce80c..a6e1c9cbc 100755 --- a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java @@ -32,6 +32,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import javax.validation.Validation; import javax.validation.ValidationException; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; @@ -72,8 +73,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio private final KserveClient kserveClient; - @Getter - private static final Map configRequestMap = new HashMap<>(); + @Getter(AccessLevel.PACKAGE) + private final Map configRequestMap = new HashMap<>(); private static class ThreadConfig { diff --git a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidator.java b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidator.java index 5cffa48f8..bbf00b4cd 100755 --- a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidator.java +++ b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidator.java @@ -81,11 +81,12 @@ public class InferenceServiceValidator implements Runnable { private void verifyInferenceServiceStatus() throws KserveException, IOException, InterruptedException, ApiException { var isVerified = false; + String isvcStatus = null; long endTime = System.currentTimeMillis() + (timeout * 1000L); while (!isVerified && System.currentTimeMillis() < endTime) { - var output = kserveClient.getInferenceServiceStatus(namespace, inferenceServiceName); - isVerified = output.equalsIgnoreCase(Boolean.TRUE.toString()); + isvcStatus = kserveClient.getInferenceServiceStatus(namespace, inferenceServiceName); + isVerified = isvcStatus.equalsIgnoreCase(Boolean.TRUE.toString()); if (!isVerified) { logger.info("Waiting for the inference service {} to be active ", inferenceServiceName); // Recheck status of pods in specific intervals. @@ -95,7 +96,11 @@ public class InferenceServiceValidator implements Runnable { } } if (!isVerified) { - throw new KserveException("Time out Exception verifying the status of the inference service"); + if (isvcStatus != null && isvcStatus.isEmpty()) { + throw new KserveException("Kserve setup is unavailable for inference service to be deployed"); + } else { + throw new KserveException("Time out Exception verifying the status of the inference service"); + } } } } -- cgit 1.2.3-korg