ningyougang commented on code in PR #5313:
URL: https://github.com/apache/openwhisk/pull/5313#discussion_r949730286
##########
core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala:
##########
@@ -462,32 +539,30 @@ object ContainerManager {
list
}
- private def chooseInvokerFromCandidates(
- candidates: List[InvokerHealth],
- wholeInvokers: List[InvokerHealth],
- pairs: List[ScheduledPair],
- msg: ContainerCreationMessage)(implicit logging: Logging):
(List[ScheduledPair], List[InvokerHealth]) = {
- val idx = rng(mod = candidates.size)
- val instance = candidates(idx)
- // it must be compared to the instance unique id
- val idxInWhole = wholeInvokers.indexOf(wholeInvokers.filter(p =>
p.id.instance == instance.id.instance).head)
- val requiredMemory = msg.whiskActionMetaData.limits.memory.megabytes
- val updated =
- if (instance.id.userMemory.toMB - requiredMemory >= requiredMemory) { //
Since ByteSize is negative, it converts to long type and compares.
- wholeInvokers.updated(
- idxInWhole,
- instance.copy(id = instance.id.copy(userMemory =
instance.id.userMemory - requiredMemory.MB)))
+ @tailrec
+ protected[container] def chooseInvokerFromCandidates(candidates:
List[InvokerHealth], msg: ContainerCreationMessage)(
+ implicit logging: Logging): ScheduledPair = {
+ val requiredMemory = msg.whiskActionMetaData.limits.memory
+ if (candidates.isEmpty) {
+ ScheduledPair(msg, invokerId = None, Some(NoAvailableInvokersError),
Some(s"No available invokers."))
+ } else if (candidates.forall(p => p.id.userMemory.toMB <
requiredMemory.megabytes)) {
+ ScheduledPair(msg, invokerId = None, Some(NoAvailableInvokersError),
Some(s"No available invokers."))
Review Comment:
Seems case1 and case2's reason is same `No available invokers`
But they has small difference, e.g. case2, No available invokers with lack
memory.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]