Conversation
58fdb50 to
12467b7
Compare
| def parse(msg: String) = Try(format.read(msg.parseJson)) | ||
| } | ||
|
|
||
| case class ByteSizeMessage(userMemory: ByteSize) extends Message { |
There was a problem hiding this comment.
I think the name should denote its purpose more.
There was a problem hiding this comment.
hm.. already changed it from ByteSizeMessage to UserMemoryMessage
| ``` | ||
| 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' |
There was a problem hiding this 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.
There was a problem hiding this 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"}]
'
| case RescheduleJob => | ||
| freePool = freePool - sender() | ||
| busyPool = busyPool - sender() | ||
| case message: ByteSizeMessage => |
There was a problem hiding this comment.
I hope this also has a more detailed protocol.
This might be extended for general configurations.
| 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 |
There was a problem hiding this comment.
I hope we can avoid using var if possible.
There was a problem hiding this comment.
hm.. seems the lastUserMemory need to support changable
There was a problem hiding this comment.
I think we can take advantage of Option.
| s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}") | ||
| latestUserMemory = message.userMemory | ||
| case UserMemoryQuery => | ||
| sender() ! latestUserMemory.toString |
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this comment.
Ok since this is just a ByteSize I think we can take this approach.
| entity(as[String]) { memory => | ||
| try { | ||
| val userMemoryMessage = ByteSizeMessage(ByteSize.fromString(memory)) | ||
| if (userMemoryMessage.userMemory.size == 0) { |
There was a problem hiding this 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.
There was a problem hiding this comment.
Updated accordingly, the user meomry can't be less than MemoryLimit.min
| logging.info( | ||
| this, | ||
| s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}") | ||
| latestUserMemory = message.userMemory |
There was a problem hiding this 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.
f9dd602 to
c7f68ff
Compare
| * @param userMemory | ||
| * @param targetInvokers | ||
| */ | ||
| def sendUserMemoryToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {} |
There was a problem hiding this comment.
How about changing the name like this?
| def sendUserMemoryToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {} | |
| def sendChangeRequestToInvoker(userMemoryMessage: UserMemoryMessage, targetInvoker: Int): Unit = {} |
| extractCredentials { | ||
| case Some(BasicHttpCredentials(username, password)) => | ||
| if (username == controllerCredentials.username && password == controllerCredentials.password) { | ||
| entity(as[String]) { memory => |
There was a problem hiding this comment.
Can't we directly convert this to ConfigMemoryList?
| entity(as[String]) { memory => | ||
| val configMemoryList = memory.parseJson.convertTo[ConfigMemoryList] | ||
|
|
||
| val existIllegalUserMemory = configMemoryList.items.exists { configMemory => |
There was a problem hiding this 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 =>
}
| 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 |
There was a problem hiding this comment.
I think we can take advantage of Option.
| s"user memory is reconfigured from ${latestUserMemory.toString} to ${message.userMemory.toString}") | ||
| latestUserMemory = message.userMemory | ||
| case UserMemoryQuery => | ||
| sender() ! latestUserMemory.toString |
There was a problem hiding this comment.
Ok since this is just a ByteSize I think we can take this approach.
| invoker: InvokerCore)(implicit ec: ExecutionContext, actorSystem: ActorSystem, logger: Logging): BasicRasService | ||
| } | ||
|
|
||
| object DefaultInvokerServer extends InvokerServerProvider { |
There was a problem hiding this comment.
Why is this removed?
This is being used.
https://github.com/apache/openwhisk/blob/master/common/scala/src/main/resources/reference.conf#L30
There was a problem hiding this comment.
I moved it to core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/DefaultInvokerServer.scala
| } | ||
|
|
||
| case class ConfigMemory(invoker: Int, memory: ByteSize) | ||
| case class ConfigMemoryList(items: List[ConfigMemory]) |
There was a problem hiding this comment.
I believe we can directly unmarshal a list of ConfigMemory rather than haveing this case class.
| def parse(msg: String) = Try(serdes.read(msg.parseJson)) | ||
| } | ||
|
|
||
| case class ConfigMemory(invoker: Int, memory: ByteSize) |
There was a problem hiding this comment.
How about changing the name to InvokerConfiguration.
We might extend this to other invoker configurations as well in the future.
c7f68ff to
65086cf
Compare
Description
Related issue and scope
My changes affect the following components
Types of changes
Checklist: