From e0e594659fbf3db10fa016b9d33a097d002d91f4 Mon Sep 17 00:00:00 2001 From: Raghuveer Raavi Date: Fri, 2 Oct 2020 10:45:52 -0400 Subject: [PATCH] Updated to ActivationThrottler to compute limit and compare against totalInflightActivations in cluster --- .../scala/org/apache/openwhisk/http/ErrorResponse.scala | 2 +- .../openwhisk/core/entitlement/ActivationThrottler.scala | 8 ++++---- tests/src/test/scala/limits/ThrottleTests.scala | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/scala/src/main/scala/org/apache/openwhisk/http/ErrorResponse.scala b/common/scala/src/main/scala/org/apache/openwhisk/http/ErrorResponse.scala index 96654466d03..5424dd309f7 100644 --- a/common/scala/src/main/scala/org/apache/openwhisk/http/ErrorResponse.scala +++ b/common/scala/src/main/scala/org/apache/openwhisk/http/ErrorResponse.scala @@ -72,7 +72,7 @@ object Messages { /** Standard message for too many concurrent activation requests within a time window. */ def tooManyConcurrentRequests(count: Int, allowed: Int) = - s"Too many concurrent requests in flight (currently running: $count, allowed per controller: $allowed)." + s"Too many concurrent requests in flight (count: $count, allowed: $allowed)." /** System overload message. */ val systemOverloaded = "System is overloaded, try again later." diff --git a/core/controller/src/main/scala/org/apache/openwhisk/core/entitlement/ActivationThrottler.scala b/core/controller/src/main/scala/org/apache/openwhisk/core/entitlement/ActivationThrottler.scala index 9d8b8829ac1..4fda661fd2b 100644 --- a/core/controller/src/main/scala/org/apache/openwhisk/core/entitlement/ActivationThrottler.scala +++ b/core/controller/src/main/scala/org/apache/openwhisk/core/entitlement/ActivationThrottler.scala @@ -39,12 +39,12 @@ class ActivationThrottler(loadBalancer: LoadBalancer, concurrencyLimit: Identity * Checks whether the operation should be allowed to proceed. */ def check(user: Identity)(implicit tid: TransactionId): Future[RateLimit] = { - loadBalancer.activeActivationsFor(user.namespace.uuid).map { concurrentActivations => - val currentLimit = concurrencyLimit(user) + loadBalancer.totalActiveActivations.map { totalInflightActivations => + val currentLimit = concurrencyLimit(user) * loadBalancer.clusterSize logging.debug( this, - s"namespace = ${user.namespace.uuid.asString}, concurrent activations = $concurrentActivations, below limit = $currentLimit") - ConcurrentRateLimit(concurrentActivations, currentLimit) + s"namespace = ${user.namespace.uuid.asString}, total inflight activations = $totalInflightActivations, limit = $currentLimit") + ConcurrentRateLimit(totalInflightActivations, currentLimit) } } } diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala index 9f76ff4f0c3..7b9e00fad60 100644 --- a/tests/src/test/scala/limits/ThrottleTests.scala +++ b/tests/src/test/scala/limits/ThrottleTests.scala @@ -467,7 +467,7 @@ class NamespaceSpecificThrottleTests } wsk.action.invoke(actionName, expectedExitCode = TooManyRequests.intValue).stderr should { - include(prefix(tooManyConcurrentRequests(0, 0))) and include("allowed per controller: 0") + include(prefix(tooManyConcurrentRequests(0, 0))) and include("allowed: 0") } }