use of io.kubernetes.client.openapi.models.V1ContainerStateTerminated in project pravega by pravega.
the class K8sClient method waitUntilPodCompletes.
/**
* A method which returns a completed future once a given Pod has completed execution. This is useful to track test execution.
* This method uses a Watch to track the status of the pod. The maximum wait time is based on the retry configuration.
* @param namespace Namespace.
* @param podName Pod name.
* @return A future which is complete once the pod completes.
*/
public CompletableFuture<V1ContainerStateTerminated> waitUntilPodCompletes(final String namespace, final String podName) {
return retryWithBackoff.retryWhen(t -> {
Throwable ex = Exceptions.unwrap(t);
// Incase of an IO Exception the Kubernetes client wraps the IOException within a RuntimeException.
if (ex.getCause() instanceof IOException) {
// IOException might occur due multiple reasons, one among them is SocketTimeout exception.
// This is observed on long running pods.
log.warn("IO Exception while fetching status of pod, will attempt a retry. Details: {}", ex.getMessage());
return true;
}
log.error("Exception while fetching status of pod", ex);
return false;
}).runAsync(() -> {
CompletableFuture<V1ContainerStateTerminated> future = new CompletableFuture<>();
V1ContainerStateTerminated state = createAWatchAndReturnOnTermination(namespace, podName).orElseThrow(() -> new RuntimeException("Watch did not return terminated state for pod " + podName));
future.complete(state);
return future;
}, executor);
}
Aggregations