You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/03/11 22:17:56 UTC

[GitHub] [openwhisk] dgrove-oss commented on a change in pull request #4857: change the kubernetes pod wait logic to use akka after pattern

dgrove-oss commented on a change in pull request #4857: change the kubernetes pod wait logic to use akka after pattern 
URL: https://github.com/apache/openwhisk/pull/4857#discussion_r391301979
 
 

 ##########
 File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
 ##########
 @@ -274,6 +275,29 @@ class KubernetesClient(
     implicit val kubernetes = this
     new KubernetesContainer(id, addr, workerIP, nativeContainerId, portFwd)
   }
+  // check for ready status every 1 second until timeout (minus the start time, which is the time for the pod create call) has past
+  private def waitForPod(namespace: String,
+                         pod: Pod,
+                         start: Instant,
+                         timeout: FiniteDuration,
+                         deadlineOpt: Option[Deadline] = None): Future[Pod] = {
+    val readyPod = kubeRestClient
+      .pods()
+      .inNamespace(namespace)
+      .withName(pod.getMetadata.getName)
+    val deadline = deadlineOpt.getOrElse((timeout - (System.currentTimeMillis() - start.toEpochMilli).millis).fromNow)
+    if (!readyPod.isReady) {
+      if (deadline.isOverdue()) {
+        Future.failed(KubernetesPodReadyTimeoutException(timeout))
+      } else {
+        after(1.seconds, scheduler) {
+          waitForPod(namespace, pod, start, timeout, Some(deadline))
 
 Review comment:
   Is Scala smart enough to convert tail calls into loops, or is there a risk of blowing the stack here with a long sequence of recursive calls?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services