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 2020/06/09 16:36:30 UTC

[GitHub] [openwhisk] ningyougang opened a new pull request #4917: Adjust user memory via api

ningyougang opened a new pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917


   <!--- Provide a concise summary of your changes in the Title -->
   
   ## Description
   <!--- Provide a detailed description of your changes. -->
   <!--- Include details of what problem you are solving and how your changes are tested. -->
   - [x] Ajust invoker's containerPool's userMemory via API
   
   ## Related issue and scope
   <!--- Please include a link to a related issue if there is one. -->
   - [ ] I opened an issue to propose and discuss this change (#????)
   
   ## My changes affect the following components
   <!--- Select below all system components are affected by your change. -->
   <!--- Enter an `x` in all applicable boxes. -->
   - [ ] API
   - [x] Controller
   - [ ] Message Bus (e.g., Kafka)
   - [ ] Loadbalancer
   - [x] Invoker
   - [ ] Intrinsic actions (e.g., sequences, conductors)
   - [ ] Data stores (e.g., CouchDB)
   - [x] Tests
   - [ ] Deployment
   - [ ] CLI
   - [ ] General tooling
   - [x] Documentation
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Use `x` in all the boxes that apply: -->
   - [ ] Bug fix (generally a non-breaking change which closes an issue).
   - [x] Enhancement or new feature (adds new functionality).
   - [ ] Breaking change (a bug fix or enhancement which changes existing behavior).
   
   ## Checklist:
   <!--- Please review the points below which help you make sure you've covered all aspects of the change you're making. -->
   
   - [x] I signed an [Apache CLA](https://github.com/apache/openwhisk/blob/master/CONTRIBUTING.md).
   - [x] I reviewed the [style guides](https://github.com/apache/openwhisk/wiki/Contributing:-Git-guidelines#code-readiness) and followed the recommendations (Travis CI will check :).
   - x ] I added tests to cover my changes.
   - [ ] My changes require further changes to the documentation.
   - [x] I updated the documentation where necessary.
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r505127738



##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -305,6 +308,13 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
     case RescheduleJob =>
       freePool = freePool - sender()
       busyPool = busyPool - sender()
+    case message: ByteSizeMessage =>
+      logging.info(
+        this,
+        s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}")
+      latestUserMemory = message.userMemory
+    case UserMemoryQuery =>
+      sender() ! latestUserMemory.toString

Review comment:
       hm..
   When we want to change invoker's user memory, in this pr, need to send the request to controller, there has one benefit  that can modfiy many invoker's user memory with one request only. e.g.
   ```
   curl  -u admin:admin -X POST http://xxx.xxx.xxx.xxx:10001/config/memory  -d '
   [
   {"invoker":0,"memory": "20480 MB"},
   {"invoker":1,"memory": "10240 MB"}
   {"invoker":2,"memory": "51200 MB"}
   ]
   '
   ```
   if send `change invoker user memory` request to invokerServer, if want to modify many invokers's user memory, need to send http request many times.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] style95 commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
style95 commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r484843664



##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -426,3 +426,22 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class ByteSizeMessage(userMemory: ByteSize) extends Message {

Review comment:
       I think the name should denote its purpose more.
   

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -305,6 +308,13 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
     case RescheduleJob =>
       freePool = freePool - sender()
       busyPool = busyPool - sender()
+    case message: ByteSizeMessage =>

Review comment:
       I hope this also has a more detailed protocol.
   This might be extended for general configurations.
   

##########
File path: docs/operation.md
##########
@@ -0,0 +1,33 @@
+<!--
+#
+# 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.
+#
+-->
+
+# User memory configuration of containerPool
+## Change user memory to all invokers via controller. e.g.
+```
+curl -u ${username}:${password} -X POST http://${controllerAddress}:${controllerPort}/config/memory -d '1024 MB'
+```
+Note: you can add `?limit` to specify target invokers, e.g. specify invoker0 and invoker1
+```
+curl -u ${username}:${password} -X POST http://${controllerAddress}:${controllerPort}/config/memory?limit=0:1 -d '1024 MB'

Review comment:
       I feel this API should be based on JSON and have a better protocol.
   For example, the name of the invoker may not be simple like just `invoker0`.
   

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -305,6 +308,13 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
     case RescheduleJob =>
       freePool = freePool - sender()
       busyPool = busyPool - sender()
+    case message: ByteSizeMessage =>
+      logging.info(
+        this,
+        s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}")
+      latestUserMemory = message.userMemory

Review comment:
       Even if controllers check the validity of this value, it would be great to cross-check the value again in the invoker layer.
   
   And regarding the check, I feel the application should not concern the condition of the underlying host.
   But on the other hand, I am not sure it would be reasonable to allow a bigger memory than the invoker host has.
   
   I would defer this to other reviewers.
   

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -74,6 +76,7 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
   var busyPool = immutable.Map.empty[ActorRef, ContainerData]
   var prewarmedPool = immutable.Map.empty[ActorRef, PreWarmedData]
   var prewarmStartingPool = immutable.Map.empty[ActorRef, (String, ByteSize)]
+  var latestUserMemory = poolConfig.userMemory

Review comment:
       I hope we can avoid using `var` if possible.

##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -176,6 +184,63 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerCredentials = loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+  /**
+   * config user memory of ContainerPool
+   */
+  private val configMemory = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "memory") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerCredentials.username && password == controllerCredentials.password) {
+            entity(as[String]) { memory =>
+              try {
+                val userMemoryMessage = ByteSizeMessage(ByteSize.fromString(memory))
+                if (userMemoryMessage.userMemory.size == 0) {

Review comment:
       I think this is not the only precondition to configure memory.
   This value can be smaller than `MemoryLimit.min` then invokers would not be able to run any container.
   

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -305,6 +308,13 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
     case RescheduleJob =>
       freePool = freePool - sender()
       busyPool = busyPool - sender()
+    case message: ByteSizeMessage =>
+      logging.info(
+        this,
+        s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}")
+      latestUserMemory = message.userMemory
+    case UserMemoryQuery =>
+      sender() ! latestUserMemory.toString

Review comment:
       How about sending the intact obejct directly and handle the type conversion in the InvokerServer layer?
   I think this kind of type conversion is only related to the InvokerServer and the client.
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r505127922



##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -74,6 +76,7 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
   var busyPool = immutable.Map.empty[ActorRef, ContainerData]
   var prewarmedPool = immutable.Map.empty[ActorRef, PreWarmedData]
   var prewarmStartingPool = immutable.Map.empty[ActorRef, (String, ByteSize)]
+  var latestUserMemory = poolConfig.userMemory

Review comment:
       hm.. seems the `lastUserMemory` need to support `changable`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] style95 commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
style95 commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r523418447



##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/LoadBalancer.scala
##########
@@ -60,6 +60,14 @@ trait LoadBalancer {
   def publish(action: ExecutableWhiskActionMetaData, msg: ActivationMessage)(
     implicit transid: TransactionId): Future[Future[Either[ActivationId, WhiskActivation]]]
 
+  /**
+   * send user memory to invokers
+   *
+   * @param userMemory
+   * @param targetInvokers
+   */
+  def sendUserMemoryToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {}

Review comment:
       How about changing the name like this?
   
   ```suggestion
     def sendChangeRequestToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {}
   ```

##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -176,6 +184,43 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerCredentials = loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+  /**
+   * config user memory of ContainerPool
+   */
+  import org.apache.openwhisk.core.connector.ConfigMemoryProtocol._
+  private val configMemory = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "memory") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerCredentials.username && password == controllerCredentials.password) {
+            entity(as[String]) { memory =>

Review comment:
       Can't we directly convert this to `ConfigMemoryList`?
   

##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -176,6 +184,43 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerCredentials = loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+  /**
+   * config user memory of ContainerPool
+   */
+  import org.apache.openwhisk.core.connector.ConfigMemoryProtocol._
+  private val configMemory = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "memory") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerCredentials.username && password == controllerCredentials.password) {
+            entity(as[String]) { memory =>
+              val configMemoryList = memory.parseJson.convertTo[ConfigMemoryList]
+
+              val existIllegalUserMemory = configMemoryList.items.exists { configMemory =>

Review comment:
       Scalaism. I think we can change this something like this:
   
   configMemoryList.items.find(MemoryLimit.MIN_MEMORY.compare(_.memory) > 0)) match {
    case Some(_) => 
      // reject the request
    case None =>
   }

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -74,6 +76,7 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
   var busyPool = immutable.Map.empty[ActorRef, ContainerData]
   var prewarmedPool = immutable.Map.empty[ActorRef, PreWarmedData]
   var prewarmStartingPool = immutable.Map.empty[ActorRef, (String, ByteSize)]
+  var latestUserMemory = poolConfig.userMemory

Review comment:
       I think we can take advantage of `Option`.
   

##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -427,3 +427,43 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class UserMemoryMessage(userMemory: ByteSize) extends Message {
+  override def serialize = UserMemoryMessage.serdes.write(this).compactPrint
+}
+
+object UserMemoryMessage extends DefaultJsonProtocol {
+  implicit val serdes = new RootJsonFormat[UserMemoryMessage] {
+    override def write(message: UserMemoryMessage): JsValue = {
+      JsObject("userMemory" -> JsString(message.userMemory.toString))
+    }
+
+    override def read(json: JsValue): UserMemoryMessage = {
+      val userMemory = fromField[String](json, "userMemory")
+      new UserMemoryMessage(ByteSize.fromString(userMemory))
+    }
+  }
+
+  def parse(msg: String) = Try(serdes.read(msg.parseJson))
+}
+
+case class ConfigMemory(invoker: Int, memory: ByteSize)
+case class ConfigMemoryList(items: List[ConfigMemory])

Review comment:
       I believe we can directly unmarshal a list of `ConfigMemory` rather than haveing this case class.

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala
##########
@@ -220,9 +223,3 @@ trait InvokerServerProvider extends Spi {
   def instance(
     invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService
 }
-
-object DefaultInvokerServer extends InvokerServerProvider {

Review comment:
       Why is this removed?
   This is being used.
   https://github.com/apache/openwhisk/blob/master/common/scala/src/main/resources/reference.conf#L30
   

##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -427,3 +427,43 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class UserMemoryMessage(userMemory: ByteSize) extends Message {
+  override def serialize = UserMemoryMessage.serdes.write(this).compactPrint
+}
+
+object UserMemoryMessage extends DefaultJsonProtocol {
+  implicit val serdes = new RootJsonFormat[UserMemoryMessage] {
+    override def write(message: UserMemoryMessage): JsValue = {
+      JsObject("userMemory" -> JsString(message.userMemory.toString))
+    }
+
+    override def read(json: JsValue): UserMemoryMessage = {
+      val userMemory = fromField[String](json, "userMemory")
+      new UserMemoryMessage(ByteSize.fromString(userMemory))
+    }
+  }
+
+  def parse(msg: String) = Try(serdes.read(msg.parseJson))
+}
+
+case class ConfigMemory(invoker: Int, memory: ByteSize)

Review comment:
       How about changing the name to `InvokerConfiguration`.
   We might extend this to other invoker configurations as well in the future.
   

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
##########
@@ -305,6 +308,13 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
     case RescheduleJob =>
       freePool = freePool - sender()
       busyPool = busyPool - sender()
+    case message: ByteSizeMessage =>
+      logging.info(
+        this,
+        s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}")
+      latestUserMemory = message.userMemory
+    case UserMemoryQuery =>
+      sender() ! latestUserMemory.toString

Review comment:
       Ok since this is just a `ByteSize` I think we can take this approach.
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r585406635



##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -176,6 +184,43 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerCredentials = loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+  /**
+   * config user memory of ContainerPool
+   */
+  import org.apache.openwhisk.core.connector.ConfigMemoryProtocol._
+  private val configMemory = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "memory") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerCredentials.username && password == controllerCredentials.password) {
+            entity(as[String]) { memory =>

Review comment:
       Yes, updated.

##########
File path: core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala
##########
@@ -220,9 +223,3 @@ trait InvokerServerProvider extends Spi {
   def instance(
     invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService
 }
-
-object DefaultInvokerServer extends InvokerServerProvider {

Review comment:
       I moved it to core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/DefaultInvokerServer.scala

##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/LoadBalancer.scala
##########
@@ -60,6 +60,14 @@ trait LoadBalancer {
   def publish(action: ExecutableWhiskActionMetaData, msg: ActivationMessage)(
     implicit transid: TransactionId): Future[Future[Either[ActivationId, WhiskActivation]]]
 
+  /**
+   * send user memory to invokers
+   *
+   * @param userMemory
+   * @param targetInvokers
+   */
+  def sendUserMemoryToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {}

Review comment:
       Updated

##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -427,3 +427,43 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class UserMemoryMessage(userMemory: ByteSize) extends Message {
+  override def serialize = UserMemoryMessage.serdes.write(this).compactPrint
+}
+
+object UserMemoryMessage extends DefaultJsonProtocol {
+  implicit val serdes = new RootJsonFormat[UserMemoryMessage] {
+    override def write(message: UserMemoryMessage): JsValue = {
+      JsObject("userMemory" -> JsString(message.userMemory.toString))
+    }
+
+    override def read(json: JsValue): UserMemoryMessage = {
+      val userMemory = fromField[String](json, "userMemory")
+      new UserMemoryMessage(ByteSize.fromString(userMemory))
+    }
+  }
+
+  def parse(msg: String) = Try(serdes.read(msg.parseJson))
+}
+
+case class ConfigMemory(invoker: Int, memory: ByteSize)

Review comment:
       Updated

##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -427,3 +427,43 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class UserMemoryMessage(userMemory: ByteSize) extends Message {
+  override def serialize = UserMemoryMessage.serdes.write(this).compactPrint
+}
+
+object UserMemoryMessage extends DefaultJsonProtocol {
+  implicit val serdes = new RootJsonFormat[UserMemoryMessage] {
+    override def write(message: UserMemoryMessage): JsValue = {
+      JsObject("userMemory" -> JsString(message.userMemory.toString))
+    }
+
+    override def read(json: JsValue): UserMemoryMessage = {
+      val userMemory = fromField[String](json, "userMemory")
+      new UserMemoryMessage(ByteSize.fromString(userMemory))
+    }
+  }
+
+  def parse(msg: String) = Try(serdes.read(msg.parseJson))
+}
+
+case class ConfigMemory(invoker: Int, memory: ByteSize)
+case class ConfigMemoryList(items: List[ConfigMemory])

Review comment:
       Updated




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r504523313



##########
File path: docs/operation.md
##########
@@ -0,0 +1,33 @@
+<!--
+#
+# 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.
+#
+-->
+
+# User memory configuration of containerPool
+## Change user memory to all invokers via controller. e.g.
+```
+curl -u ${username}:${password} -X POST http://${controllerAddress}:${controllerPort}/config/memory -d '1024 MB'
+```
+Note: you can add `?limit` to specify target invokers, e.g. specify invoker0 and invoker1
+```
+curl -u ${username}:${password} -X POST http://${controllerAddress}:${controllerPort}/config/memory?limit=0:1 -d '1024 MB'

Review comment:
       Currently, i changed it to like below
   ```
   curl  -u admin:admin -X POST http://xxx.xxx.xxx.xxx:10001/config/memory  -d '
   [{"invoker":0,"memory": "20480 MB"}, {"invoker":1,"memory": "10240 MB"}]
   '
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r504522510



##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -176,6 +184,63 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerCredentials = loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+  /**
+   * config user memory of ContainerPool
+   */
+  private val configMemory = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "memory") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerCredentials.username && password == controllerCredentials.password) {
+            entity(as[String]) { memory =>
+              try {
+                val userMemoryMessage = ByteSizeMessage(ByteSize.fromString(memory))
+                if (userMemoryMessage.userMemory.size == 0) {

Review comment:
       Updated accordingly, the user meomry can't be less than `MemoryLimit.min`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang commented on a change in pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang commented on a change in pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917#discussion_r504522155



##########
File path: common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
##########
@@ -426,3 +426,22 @@ object EventMessage extends DefaultJsonProtocol {
 
   def parse(msg: String) = Try(format.read(msg.parseJson))
 }
+
+case class ByteSizeMessage(userMemory: ByteSize) extends Message {

Review comment:
       hm.. already changed it from `ByteSizeMessage` to `UserMemoryMessage`




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [openwhisk] ningyougang closed pull request #4917: Adjust user memory via api

Posted by GitBox <gi...@apache.org>.
ningyougang closed pull request #4917:
URL: https://github.com/apache/openwhisk/pull/4917


   


----------------------------------------------------------------
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:
users@infra.apache.org