tysonnorris commented on a change in pull request #2659: Containerfactory SPI
URL: 
https://github.com/apache/incubator-openwhisk/pull/2659#discussion_r137584934
 
 

 ##########
 File path: core/invoker/src/main/scala/whisk/core/invoker/InvokerReactive.scala
 ##########
 @@ -72,31 +69,12 @@ class InvokerReactive(config: WhiskConfig, instance: 
InstanceId, producer: Messa
             consumer, maximumContainers, 500.milliseconds, 
processActivationMessage)
     })
 
-    /** Initialize container clients */
-    implicit val docker = new DockerClientWithFileAccess()(ec)
-    implicit val runc = new RuncClient(ec)
-
-    /** Cleans up all running wsk_ containers */
-    def cleanup() = {
-        val cleaning = docker.ps(Seq("name" -> 
s"wsk${instance.toInt}_"))(TransactionId.invokerNanny).flatMap { containers =>
-            val removals = containers.map { id =>
-                runc.resume(id)(TransactionId.invokerNanny).recoverWith {
-                    // Ignore resume failures and try to remove anyway
-                    case _ => Future.successful(())
-                }.flatMap {
-                    _ => docker.rm(id)(TransactionId.invokerNanny)
-                }
-            }
-            Future.sequence(removals)
-        }
-
-        Await.ready(cleaning, 30.seconds)
-    }
-    cleanup()
-    sys.addShutdownHook(cleanup())
 
     /** Factory used by the ContainerProxy to physically create a new 
container. */
-    val containerFactory = 
SpiLoader.get[ContainerFactoryProvider]().getContainerFactory(actorSystem, 
logging, config).createContainer _
+    val containerFactory = 
SpiLoader.get[ContainerFactoryProvider].getContainerFactory(actorSystem, 
logging, config, instance)
+    val containerFactoryFunction = containerFactory.createContainer _
+    containerFactory.cleanup()
+    sys.addShutdownHook(containerFactory.cleanup())
 
 Review comment:
   This is the same syntax that was there before; I tested it and it does the 
right thing - runs once at startup, and once at shutdown. 
 
----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to