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/16 12:07:53 UTC

[GitHub] sven-lange-last commented on a change in pull request #4176: additional container factory dns configuration

sven-lange-last commented on a change in pull request #4176: additional container factory dns configuration
URL: https://github.com/apache/incubator-openwhisk/pull/4176#discussion_r248255952
 
 

 ##########
 File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala
 ##########
 @@ -98,6 +99,13 @@ class DockerClient(dockerHost: Option[String] = None,
     Seq(dockerBin) ++ host
   }
 
+  // Determine the version of the docker client cli.  Failure to determine the client
+  // version implies a failure to initialize this instance of DockerClient.
+  protected def getClientVersion(): String = {
+    stringSeqToProcess(dockerCmd ++ Seq("version", "--format", "{{.Client.Version}}")).!!
+  }
+  val clientVersion: String = getClientVersion()
 
 Review comment:
   Sorry for being picky here although you already followed my proposal to use the Docker CLI command to determine the version...
   
   Documentation of the `!!` method states: "If the exit code is non-zero, an exception is thrown.". In other words, the `getClientVersion()` invocation may fail with an exception which is uncaught. As a consequence creation of the `DockerClient` instance as part of the invoker initialisation may fail due to the exception. That's a rather high risk for just determining the Docker version.
   
   In addition, `!!` writes the executed command's stderr to the console instead of capturing it. So we have no good diagnostic info available in case of a failure.
   
   I suggest to make `getClientVersion()` fail-safe and return an `Option[String]`: it's `None` upon failure indicating we don't know the version and the version string on success. So `clientVersion` also needs to be an `Option[String]`.
   
   On failure, `getClientVersion()` needs to log an error such that we know about the problem. Probably, we should use the `executeProcess` method instead of `!!`. It already comes with full output capturing and timeout handling.
   
   The rest of the code needs to deal with an unknown version gracefully. If that's not possible, we have to throw a meaningful exception and stop invoker init with a reasonable error message.

----------------------------------------------------------------
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