bdoyle0182 commented on code in PR #5344:
URL: https://github.com/apache/openwhisk/pull/5344#discussion_r1009833309


##########
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:
   Added two test cases to cover 1. when need to add containers both for stale 
messages and increase tps for non-stale available messages 2. when only need to 
add container to cover stale messages and tps is still met for non-stale 
messages.
   
   Would appreciate approval on this one too when you have some time @style95 



-- 
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]

Reply via email to