From ae1e9743ac0a2c8df64dd9e86f0a58b45b367304 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 30 Jan 2024 20:16:19 +0100 Subject: [PATCH] Check if job container status is completed Signed-off-by: David Kornel --- .../java/io/odh/test/framework/manager/ResourceManager.java | 2 +- src/main/java/io/odh/test/utils/PodUtils.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/odh/test/framework/manager/ResourceManager.java b/src/main/java/io/odh/test/framework/manager/ResourceManager.java index ed9de604..587e0947 100644 --- a/src/main/java/io/odh/test/framework/manager/ResourceManager.java +++ b/src/main/java/io/odh/test/framework/manager/ResourceManager.java @@ -149,7 +149,7 @@ private void createResource(boolean waitReady, T... reso } } } else { - if (client.getClient().resource(resource).get() != null) { + if (type.get(resource.getMetadata().getNamespace(), resource.getMetadata().getName()) != null) { type.update(resource); } else { type.create(resource); diff --git a/src/main/java/io/odh/test/utils/PodUtils.java b/src/main/java/io/odh/test/utils/PodUtils.java index f0448f6a..cfff7a80 100644 --- a/src/main/java/io/odh/test/utils/PodUtils.java +++ b/src/main/java/io/odh/test/utils/PodUtils.java @@ -43,7 +43,8 @@ public static void waitForPodsReady(String namespaceName, boolean containers, Ru } else { if (containers) { for (ContainerStatus cs : pod.getStatus().getContainerStatuses()) { - if (!Boolean.TRUE.equals(cs.getReady())) { + if (!(Boolean.TRUE.equals(cs.getReady()) + || cs.getState().getAdditionalProperties().getOrDefault("Reason", "none").equals("Completed"))) { LOGGER.debug("Container: {} of Pod: {}/{} not ready", namespaceName, pod.getMetadata().getName(), cs.getName()); return false; } @@ -80,7 +81,8 @@ public static void waitForPodsReady(String namespaceName, LabelSelector selector } else { if (containers) { for (ContainerStatus cs : pod.getStatus().getContainerStatuses()) { - if (!Boolean.TRUE.equals(cs.getReady())) { + if (!(Boolean.TRUE.equals(cs.getReady()) + || cs.getState().getAdditionalProperties().getOrDefault("Reason", "none").equals("Completed"))) { LOGGER.debug("Container: {} of Pod: {}/{} not ready", namespaceName, pod.getMetadata().getName(), cs.getName()); return false; }