[GitHub] rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment
rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment URL: https://github.com/apache/incubator-openwhisk/pull/3669#discussion_r190364979 ## File path: common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala ## @@ -285,6 +309,24 @@ protected[core] object ExecManifest { private val defaultSplitter = "([a-z0-9]+):default".r } + protected[entity] implicit val stemCellSerdes = new RootJsonFormat[StemCell] { Review comment: there isn't but will add one and replace this. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment
rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment URL: https://github.com/apache/incubator-openwhisk/pull/3669#discussion_r190365264 ## File path: common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala ## @@ -262,13 +283,16 @@ protected[core] object ExecManifest { } } -val manifests: Map[String, RuntimeManifest] = { - runtimes.flatMap { -_.versions.map { m => - m.kind -> m -} - }.toMap -} +/** + * Collects all runtimes for which there is a stemcell configuration defined + * + * @return list of runtime manifests with stemcell configurations + */ +def stemcells[T](f: (RuntimeManifest, List[StemCell]) => List[T]): List[T] = { + manifests.collect { +case (_, m @ RuntimeManifest(_, _, _, _, _, _, _, Some(stemCells))) if stemCells.nonEmpty => f(m, stemCells) + } +}.flatten.toList Review comment: ok will adopt. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment
rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment URL: https://github.com/apache/incubator-openwhisk/pull/3669#discussion_r190365020 ## File path: common/scala/src/main/scala/whisk/core/entity/ExecManifest.scala ## @@ -285,6 +309,24 @@ protected[core] object ExecManifest { private val defaultSplitter = "([a-z0-9]+):default".r } + protected[entity] implicit val stemCellSerdes = new RootJsonFormat[StemCell] { +def write(cell: StemCell) = + JsObject("count" -> JsNumber(cell.count), "memory" -> JsString(cell.memory.toString)) + +def read(value: JsValue): StemCell = { + Try { +value.asJsObject.getFields("count", "memory") match { + case Seq(JsNumber(count), JsString(memory)) => +require(count.isWhole && count.intValue > 0, "stem cell count must be whole number greater than zero") +StemCell(count.intValue, ByteSize.fromString(memory)) +} + } match { +case Success(c) => c +case Failure(t) => throw t + } Review comment: 路♂️ will nuke. 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment
rabbah commented on a change in pull request #3669: Make stemcells configurable by deployment URL: https://github.com/apache/incubator-openwhisk/pull/3669#discussion_r188985305 ## File path: core/invoker/src/main/scala/whisk/core/containerpool/ContainerPool.scala ## @@ -204,26 +199,25 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef, * @param kind the kind you want to invoke * @return the container iff found */ - def takePrewarmContainer(action: ExecutableWhiskAction): Option[(ActorRef, ContainerData)] = -prewarmConfig.flatMap { config => - val kind = action.exec.kind - val memory = action.limits.memory.megabytes.MB - prewarmedPool -.find { - case (_, PreWarmedData(_, `kind`, `memory`)) => true - case _ => false -} -.map { - case (ref, data) => -// Move the container to the usual pool -freePool = freePool + (ref -> data) -prewarmedPool = prewarmedPool - ref -// Create a new prewarm container -prewarmContainer(config.exec, config.memoryLimit) - -(ref, data) -} -} + def takePrewarmContainer(action: ExecutableWhiskAction): Option[(ActorRef, ContainerData)] = { +val kind = action.exec.kind +val memory = action.limits.memory.megabytes.MB +prewarmedPool + .find { +case (_, PreWarmedData(_, `kind`, `memory`)) => true +case _ => false + } + .map { +case (ref, data) => + // Move the container to the usual pool + freePool = freePool + (ref -> data) + prewarmedPool = prewarmedPool - ref + // Create a new prewarm container + // NOTE: prewarming ignores the action code, but this is dangerous as the code is accessible to the factory Review comment: @markusthoemmes we should fix this separately - I don't like this but it is safe here. Please sanity check me. 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: us...@infra.apache.org With regards, Apache Git Services