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 2019/01/23 19:07:22 UTC

[GitHub] markusthoemmes commented on a change in pull request #4223: Use Stricter Retry Logic in AkkaContainerClient

markusthoemmes commented on a change in pull request #4223: Use Stricter Retry Logic in AkkaContainerClient
URL: https://github.com/apache/incubator-openwhisk/pull/4223#discussion_r250331657
 
 

 ##########
 File path: common/scala/src/main/scala/org/apache/openwhisk/core/containerpool/AkkaContainerClient.scala
 ##########
 @@ -135,13 +136,17 @@ protected class AkkaContainerClient(
                               timeout: FiniteDuration,
                               retry: Boolean,
                               retryCount: Int = 0): Future[(HttpResponse, Int)] = {
+    val start = Instant.now
+
     request(req)
       .map((_, retryCount))
       .recoverWith {
         case t: StreamTcpException if retry =>
-          val newTimeout = timeout - retryInterval
-          if (newTimeout > Duration.Zero) {
-            akka.pattern.after(retryInterval, as.scheduler)(retryingRequest(req, newTimeout, retry, retryCount + 1))
+          if (timeout > Duration.Zero) {
+            akka.pattern.after(retryInterval, as.scheduler)({
+              val newTimeout = timeout - (Instant.now.toEpochMilli - start.toEpochMilli).milliseconds
 
 Review comment:
   For future reference: you should be able to do this in a typesafe way by importing implicit conversions for durations (https://github.com/apache/incubator-openwhisk/blob/master/common/scala/src/main/scala/org/apache/openwhisk/utils/TimeHelpers.scala) and then do something along the lines of:
   
   ```scala
   timeout - Duration.between(Instant.now, start)
   ```
   
   to avoid going into Long and back.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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