From 8ba12584d1c82c204e4e4d4db2fc4a83c0da5a3e Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Mon, 9 Nov 2020 09:55:38 +0100 Subject: [PATCH] Kubernetes: wait for proxy.container-wait-time before pod is ready --- .../backend/kubernetes/KubernetesBackend.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java b/src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java index 120504e4..373f53f9 100644 --- a/src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java +++ b/src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java @@ -268,8 +268,11 @@ protected Container startContainer(ContainerSpec spec, Proxy proxy) throws Excep Pod startedPod = kubeClient.pods().inNamespace(effectiveKubeNamespace).create(patchedPod); - // Workaround: waitUntilReady appears to be buggy. - Retrying.retry(i -> Readiness.isReady(kubeClient.resource(startedPod).fromServer().get()), 60, 1000); + int totalWaitMs = Integer.parseInt(environment.getProperty("proxy.container-wait-time", "20000")); + Retrying.retry(i -> Readiness.isReady(kubeClient.resource(startedPod).fromServer().get()), totalWaitMs / 1000, 1000); + if (!Readiness.isReady(kubeClient.resource(startedPod).fromServer().get())) { + throw new ContainerProxyException("Container did not become ready in time"); + } Pod pod = kubeClient.resource(startedPod).fromServer().get(); Service service = null;