Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ODH pod readiness because DSC status is unstable #54

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.odh.test.OdhConstants;
import io.odh.test.TestConstants;
import io.odh.test.TestUtils;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.ResourceType;
import io.odh.test.platform.KubeUtils;
import io.odh.test.utils.PodUtils;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -62,6 +64,11 @@ public boolean waitForReadiness(DataScienceCluster resource) {

return dscReady;
}, () -> { });

String namespace = OdhConstants.CONTROLLERS_NAMESPACE;
LOGGER.info("Waiting for pods readiness in {}", namespace);
PodUtils.waitForPodsReady(namespace, true, () -> { });

return true;
}

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/odh/test/utils/PodUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@ public class PodUtils {

private PodUtils() { }

public static void waitForPodsReady(String namespaceName, boolean containers, Runnable onTimeout) {
TestUtils.waitFor("readiness of all Pods matching in namespace {} " + namespaceName,
TestConstants.GLOBAL_POLL_INTERVAL_MEDIUM, READINESS_TIMEOUT,
() -> {
List<Pod> pods = ResourceManager.getClient().listPods(namespaceName);
if (pods.isEmpty()) {
LOGGER.debug("Expected Pods are ready");
return true;
}
for (Pod pod : pods) {
if (!Readiness.isPodReady(pod)) {
LOGGER.debug("Pod not ready: {}/{}", namespaceName, pod.getMetadata().getName());
return false;
} else {
if (containers) {
for (ContainerStatus cs : pod.getStatus().getContainerStatuses()) {
if (!Boolean.TRUE.equals(cs.getReady())) {
LOGGER.debug("Container: {} of Pod: {}/{} not ready", namespaceName, pod.getMetadata().getName(), cs.getName());
return false;
}
}
}
}
}
LOGGER.info("Pods in namespace {} are ready", namespaceName);
return true;
}, onTimeout);
}

public static void waitForPodsReady(String namespaceName, LabelSelector selector, int expectPods, boolean containers, Runnable onTimeout) {
TestUtils.waitFor("readiness of all Pods matching: " + selector,
TestConstants.GLOBAL_POLL_INTERVAL_MEDIUM, READINESS_TIMEOUT,
Expand Down
Loading