style95 commented on code in PR #5344:
URL: https://github.com/apache/openwhisk/pull/5344#discussion_r1007731211
##########
core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/SchedulingDecisionMaker.scala:
##########
@@ -135,41 +135,44 @@ class SchedulingDecisionMaker(
staleActivationNum,
0.0,
Running)
-
- case (Running, Some(duration)) if staleActivationNum > 0 =>
- // we can safely get the value as we already checked the existence
- val containerThroughput = staleThreshold / duration
- val num = ceiling(availableMsg.toDouble / containerThroughput)
- // if it tries to create more containers than existing messages,
we just create shortage
- val actualNum = (if (num > availableMsg) availableMsg else num) -
inProgress
- addServersIfPossible(
- existing,
- inProgress,
- containerThroughput,
- availableMsg,
- capacity,
- actualNum,
- staleActivationNum,
- duration,
- Running)
-
// need more containers and a message is already processed
case (Running, Some(duration)) =>
// we can safely get the value as we already checked the existence
val containerThroughput = staleThreshold / duration
val expectedTps = containerThroughput * (existing + inProgress)
+ val availableNonStaleActivations = availableMsg -
staleActivationNum
+
+ var staleContainerProvision = 0
+ if (staleActivationNum > 0) {
+ val num = ceiling(staleActivationNum.toDouble /
containerThroughput)
+ // if it tries to create more containers than existing messages,
we just create shortage
+ staleContainerProvision = (if (num > staleActivationNum)
staleActivationNum else num) - inProgress
+ }
- if (availableMsg >= expectedTps && existing + inProgress <
availableMsg) {
- val num = ceiling((availableMsg / containerThroughput) -
existing - inProgress)
+ if (availableNonStaleActivations >= expectedTps && existing +
inProgress < availableMsg) {
+ val num = ceiling((availableNonStaleActivations /
containerThroughput) - existing - inProgress)
// if it tries to create more containers than existing messages,
we just create shortage
- val actualNum = if (num + totalContainers > availableMsg)
availableMsg - totalContainers else num
+ val actualNum =
+ if (num + totalContainers > availableNonStaleActivations)
availableNonStaleActivations - totalContainers
+ else num
+ addServersIfPossible(
Review Comment:
Can we add a unit test to cover this case?
--
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]