rabbah commented on a change in pull request #4516: Openwhisk in a standalone 
runnable jar
URL: 
https://github.com/apache/incubator-openwhisk/pull/4516#discussion_r297232393
 
 

 ##########
 File path: 
core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/StandaloneDockerContainerFactory.scala
 ##########
 @@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openwhisk.core.containerpool.docker
+
+import akka.actor.ActorSystem
+import org.apache.commons.lang3.SystemUtils
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.WhiskConfig
+import org.apache.openwhisk.core.containerpool.{Container, ContainerFactory, 
ContainerFactoryProvider}
+import org.apache.openwhisk.core.entity.{ByteSize, ExecManifest, 
InvokerInstanceId}
+import pureconfig.loadConfig
+
+import scala.collection.concurrent.TrieMap
+import scala.concurrent.{ExecutionContext, Future}
+
+object StandaloneDockerContainerFactoryProvider extends 
ContainerFactoryProvider {
+  override def instance(actorSystem: ActorSystem,
+                        logging: Logging,
+                        config: WhiskConfig,
+                        instanceId: InvokerInstanceId,
+                        parameters: Map[String, Set[String]]): 
ContainerFactory = {
+    val client =
+      if (SystemUtils.IS_OS_MAC) new 
DockerForMacClient()(actorSystem.dispatcher)(logging, actorSystem)
+      else if (SystemUtils.IS_OS_WINDOWS) new 
DockerForWindowsClient()(actorSystem.dispatcher)(logging, actorSystem)
+      else new DockerClientWithFileAccess()(actorSystem.dispatcher)(logging, 
actorSystem)
+
+    new StandaloneDockerContainerFactory(instanceId, parameters)(
+      actorSystem,
+      actorSystem.dispatcher,
+      logging,
+      client,
+      new RuncClient()(actorSystem.dispatcher)(logging, actorSystem))
+  }
+}
+
+class StandaloneDockerContainerFactory(instance: InvokerInstanceId, 
parameters: Map[String, Set[String]])(
+  implicit actorSystem: ActorSystem,
+  ec: ExecutionContext,
+  logging: Logging,
+  docker: DockerApiWithFileAccess,
+  runc: RuncApi)
+    extends DockerContainerFactory(instance, parameters) {
+  private val pulledImages = new TrieMap[String, Boolean]()
+
+  override def createContainer(tid: TransactionId,
+                               name: String,
+                               actionImage: ExecManifest.ImageName,
+                               userProvidedImage: Boolean,
+                               memory: ByteSize,
+                               cpuShares: Int)(implicit config: WhiskConfig, 
logging: Logging): Future[Container] = {
+
+    //For standalone server usage we would also want to pull the OpenWhisk 
provided image so as to ensure if
+    //local setup does not have the image then it pulls it down
+    //For standard usage its expected that standard images have already been 
pulled in.
+    val imageName = actionImage.localImageName(runtimesRegistryConfig.url)
+    val pulled = if (!userProvidedImage && !pulledImages.contains(imageName)) {
+      docker.pull(imageName)(tid).map { _ =>
 
 Review comment:
   this will be problematic if one wants to use a build images that's not on 
dockerhub yet. 
   a docker run will pull a missing image if necessary, maybe we can support 
the `bypass` options available on the invoker role today to skip pulling 
images. wdyt?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to