You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ma...@apache.org on 2017/08/19 17:37:03 UTC

[incubator-openwhisk] branch master updated: Remove defaultLimits and establish proper limit override method. (#2595)

This is an automated email from the ASF dual-hosted git repository.

markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 08e6ff4  Remove defaultLimits and establish proper limit override method. (#2595)
08e6ff4 is described below

commit 08e6ff4da684860e93839af5761cb12f2642bfde
Author: ningyougang <41...@qq.com>
AuthorDate: Sun Aug 20 01:37:00 2017 +0800

    Remove defaultLimits and establish proper limit override method. (#2595)
---
 ansible/README.md                                  | 34 ++++++++++++----------
 ansible/environments/distributed/group_vars/all    | 10 -------
 ansible/environments/docker-machine/group_vars/all | 10 -------
 ansible/environments/local/group_vars/all          | 10 -------
 ansible/environments/mac/group_vars/all            | 10 -------
 ansible/group_vars/all                             | 17 ++++-------
 ansible/roles/controller/tasks/deploy.yml          | 14 ++++-----
 ansible/templates/whisk.properties.j2              | 16 ++++------
 .../src/main/scala/whisk/core/WhiskConfig.scala    | 16 ++++------
 .../main/scala/whisk/core/controller/Actions.scala |  2 +-
 .../scala/whisk/core/controller/Controller.scala   |  4 +--
 .../scala/whisk/core/entitlement/Entitlement.scala | 15 ++++------
 tests/src/test/scala/common/WhiskProperties.java   |  3 --
 tests/src/test/scala/limits/ThrottleTests.scala    | 15 ++++------
 .../test/scala/system/basic/WskSequenceTests.scala |  2 +-
 15 files changed, 54 insertions(+), 124 deletions(-)

diff --git a/ansible/README.md b/ansible/README.md
index 6d01601..0ae63e7 100644
--- a/ansible/README.md
+++ b/ansible/README.md
@@ -282,20 +282,24 @@ the path to your OpenWhisk `ansible` directory contains spaces. To fix this, ple
 without spaces as there is no current fix available to this problem.
 
 #### Changing limits
-The system throttling limits can be changed by modifying the `group_vars` for your environment. For example,
-mac users will find the limits in this file [./environments/mac/group_vars/all](./environments/mac/group_vars/all):
+The default system throttling limits are configured in this file [./group_vars/all](./group_vars/all).
 ```
 limits:
-  actions:
-    invokes:
-      perMinute: 60
-      concurrent: 30
-      concurrentInSystem: 5000
-  triggers:
-    fires:
-      perMinute: 60
-```
-- The `perMinute` under `limits->actions->invokes` represents the allowed namespace action invocations per minute.
-- The `concurrent` under `limits->actions->invokes` represents the maximum concurrent invocations allowed per namespace.
-- The `concurrentInSystem` under `limits->actions->invokes` represents the maximum concurrent invocations the system will allow across all namespaces.
-- The `perMinute` under `limits->triggers-fires` represents the allowed namespace trigger firings per minute.
+  invocationsPerMinute: "{{ limit_invocations_per_minute | default(120) }}"
+  concurrentInvocations: "{{ limit_invocations_concurrent | default(100) }}"
+  concurrentInvocationsSystem:  "{{ limit_invocations_concurrent_system | default(5000) }}"
+  firesPerMinute: "{{ limit_fires_per_minute | default(60) }}"
+  sequenceMaxLength: "{{ limit_sequence_max_length | default(50) }}"
+```
+These values may be changed by modifying the `group_vars` for your environment. For example,
+mac users will find the limits in this file [./environments/mac/group_vars/all](./environments/mac/group_vars/all):
+```
+limit_invocations_per_minute: 60
+limit_invocations_concurrent: 30
+limit_invocations_concurrent_system: 5000
+limit_fires_per_minute: 60
+```
+- The `limit_invocations_per_minute` represents the allowed namespace action invocations per minute.
+- The `limit_invocations_concurrent` represents the maximum concurrent invocations allowed per namespace.
+- The `limit_invocations_concurrent_system` represents the maximum concurrent invocations the system will allow across all namespaces.
+- The `limit_fires_per_minute` represents the allowed namespace trigger firings per minute.
diff --git a/ansible/environments/distributed/group_vars/all b/ansible/environments/distributed/group_vars/all
index 1b4726d..4083786 100755
--- a/ansible/environments/distributed/group_vars/all
+++ b/ansible/environments/distributed/group_vars/all
@@ -22,16 +22,6 @@ registry:
     threshold: 80
     keeptags: 5
 
-limits:
-  actions:
-    invokes:
-      perMinute: 60
-      concurrent: 30
-      concurrentInSystem: 5000
-  triggers:
-    fires:
-      perMinute: 60
-
 # openstack vars
 # TODO, should move these to a role and create a designated "defaults.yml" file
 rc_file:
diff --git a/ansible/environments/docker-machine/group_vars/all b/ansible/environments/docker-machine/group_vars/all
index 08bf632..13eda6f 100644
--- a/ansible/environments/docker-machine/group_vars/all
+++ b/ansible/environments/docker-machine/group_vars/all
@@ -20,16 +20,6 @@ db_protocol: "{{ lookup('ini', 'db_protocol section=db_creds file={{ playbook_di
 db_host: "{{ lookup('ini', 'db_host section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 db_port: "{{ lookup('ini', 'db_port section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 
-limits:
-  actions:
-    invokes:
-      perMinute: 60
-      concurrent: 30
-      concurrentInSystem: 5000
-  triggers:
-    fires:
-      perMinute: 60
-
 # API GW connection configuration
 apigw_auth_user: ""
 apigw_auth_pwd: ""
diff --git a/ansible/environments/local/group_vars/all b/ansible/environments/local/group_vars/all
index c7914df..326c430 100755
--- a/ansible/environments/local/group_vars/all
+++ b/ansible/environments/local/group_vars/all
@@ -14,16 +14,6 @@ db_protocol: "{{ lookup('ini', 'db_protocol section=db_creds file={{ playbook_di
 db_host: "{{ lookup('ini', 'db_host section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 db_port: "{{ lookup('ini', 'db_port section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 
-limits:
-  actions:
-    invokes:
-      perMinute: 60
-      concurrent: 30
-      concurrentInSystem: 5000
-  triggers:
-    fires:
-      perMinute: 60
-
 # API GW connection configuration
 apigw_auth_user: ""
 apigw_auth_pwd: ""
diff --git a/ansible/environments/mac/group_vars/all b/ansible/environments/mac/group_vars/all
index c596c41..5edce83 100755
--- a/ansible/environments/mac/group_vars/all
+++ b/ansible/environments/mac/group_vars/all
@@ -14,16 +14,6 @@ db_protocol: "{{ lookup('ini', 'db_protocol section=db_creds file={{ playbook_di
 db_host: "{{ lookup('ini', 'db_host section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 db_port: "{{ lookup('ini', 'db_port section=db_creds file={{ playbook_dir }}/db_local.ini') }}"
 
-limits:
-  actions:
-    invokes:
-      perMinute: 60
-      concurrent: 30
-      concurrentInSystem: 5000
-  triggers:
-    fires:
-      perMinute: 60
-
 # API GW connection configuration
 apigw_auth_user: ""
 apigw_auth_pwd: ""
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 0f99f0d..13a2a65 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -92,17 +92,12 @@ runtimesManifest:
   blackboxes:
     - name: "dockerskeleton"
 
-defaultLimits:
-  actions:
-    invokes:
-      perMinute: 120
-      concurrent: 100
-      concurrentInSystem: 5000
-    sequence:
-      maxLength: 50
-  triggers:
-    fires:
-      perMinute: 60
+limits:
+  invocationsPerMinute: "{{ limit_invocations_per_minute | default(60) }}"
+  concurrentInvocations: "{{ limit_invocations_concurrent | default(30) }}"
+  concurrentInvocationsSystem:  "{{ limit_invocations_concurrent_system | default(5000) }}"
+  firesPerMinute: "{{ limit_fires_per_minute | default(60) }}"
+  sequenceMaxLength: "{{ limit_sequence_max_length | default(50) }}"
 
 # port means outer port
 controller:
diff --git a/ansible/roles/controller/tasks/deploy.yml b/ansible/roles/controller/tasks/deploy.yml
index 1020d33..71b6287 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -49,15 +49,11 @@
       "DB_WHISK_AUTHS": "{{ db.whisk.auth }}"
       "DB_WHISK_ACTIVATIONS": "{{ db.whisk.activations }}"
 
-      "DEFAULTLIMITS_ACTIONS_INVOKES_PERMINUTE": "{{ defaultLimits.actions.invokes.perMinute }}"
-      "DEFAULTLIMITS_ACTIONS_INVOKES_CONCURRENT": "{{ defaultLimits.actions.invokes.concurrent }}"
-      "DEFAULTLIMITS_TRIGGERS_FIRES_PERMINUTE": "{{ defaultLimits.triggers.fires.perMinute }}"
-      "DEFAULTLIMITS_ACTIONS_INVOKES_CONCURRENTINSYSTEM": "{{ defaultLimits.actions.invokes.concurrentInSystem }}"
-      "DEFAULTLIMITS_ACTIONS_SEQUENCE_MAXLENGTH": "{{ defaultLimits.actions.sequence.maxLength }}"
-      "LIMITS_ACTIONS_INVOKES_PERMINUTE": "{{ limits.actions.invokes.perMinute }}"
-      "LIMITS_ACTIONS_INVOKES_CONCURRENT": "{{ limits.actions.invokes.concurrent }}"
-      "LIMITS_ACTIONS_INVOKES_CONCURRENTINSYSTEM": "{{ limits.actions.invokes.concurrentInSystem }}"
-      "LIMITS_TRIGGERS_FIRES_PERMINUTE": "{{ limits.triggers.fires.perMinute }}"
+      "LIMITS_ACTIONS_INVOKES_PERMINUTE": "{{ limits.invocationsPerMinute }}"
+      "LIMITS_ACTIONS_INVOKES_CONCURRENT": "{{ limits.concurrentInvocations }}"
+      "LIMITS_ACTIONS_INVOKES_CONCURRENTINSYSTEM": "{{ limits.concurrentInvocationsSystem }}"
+      "LIMITS_TRIGGERS_FIRES_PERMINUTE": "{{ limits.firesPerMinute }}"
+      "LIMITS_ACTIONS_SEQUENCE_MAXLENGTH": "{{ limits.sequenceMaxLength }}"
       "LOADBALANCER_INVOKERBUSYTHRESHOLD": "{{ invoker.busyThreshold }}"
 
       "RUNTIMES_MANIFEST": "{{ runtimesManifest | to_json }}"
diff --git a/ansible/templates/whisk.properties.j2 b/ansible/templates/whisk.properties.j2
index 711653f..2d27ee7 100644
--- a/ansible/templates/whisk.properties.j2
+++ b/ansible/templates/whisk.properties.j2
@@ -34,18 +34,12 @@ whisk.api.localhost.name={{ whisk_api_localhost_name | default(whisk_api_host_na
 whisk.api.vanity.subdomain.parts=1
 
 runtimes.manifest={{ runtimesManifest | to_json }}
-defaultLimits.actions.invokes.perMinute={{ defaultLimits.actions.invokes.perMinute }}
-defaultLimits.actions.invokes.concurrent={{ defaultLimits.actions.invokes.concurrent }}
-defaultLimits.triggers.fires.perMinute={{ defaultLimits.triggers.fires.perMinute }}
-defaultLimits.actions.invokes.concurrentInSystem={{ defaultLimits.actions.invokes.concurrentInSystem }}
-defaultLimits.actions.sequence.maxLength={{ defaultLimits.actions.sequence.maxLength }}
 
-{% if limits is defined %}
-limits.actions.invokes.perMinute={{ limits.actions.invokes.perMinute }}
-limits.actions.invokes.concurrent={{ limits.actions.invokes.concurrent }}
-limits.actions.invokes.concurrentInSystem={{ limits.actions.invokes.concurrentInSystem }}
-limits.triggers.fires.perMinute={{ limits.triggers.fires.perMinute }}
-{% endif %}
+limits.actions.invokes.perMinute={{ limits.invocationsPerMinute }}
+limits.actions.invokes.concurrent={{ limits.concurrentInvocations }}
+limits.actions.invokes.concurrentInSystem={{ limits.concurrentInvocationsSystem }}
+limits.triggers.fires.perMinute={{ limits.firesPerMinute }}
+limits.actions.sequence.maxLength={{ limits.sequenceMaxLength }}
 
 edge.host={{ groups["edge"]|first }}
 kafka.host={{ groups["kafka"]|first }}
diff --git a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
index 96ff45d..289090a 100644
--- a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
+++ b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
@@ -95,11 +95,11 @@ class WhiskConfig(
 
     val runtimesManifest = this(WhiskConfig.runtimesManifest)
 
-    val actionInvokePerMinuteLimit = this(WhiskConfig.actionInvokePerMinuteDefaultLimit, WhiskConfig.actionInvokePerMinuteLimit)
-    val actionInvokeConcurrentLimit = this(WhiskConfig.actionInvokeConcurrentDefaultLimit, WhiskConfig.actionInvokeConcurrentLimit)
-    val triggerFirePerMinuteLimit = this(WhiskConfig.triggerFirePerMinuteDefaultLimit, WhiskConfig.triggerFirePerMinuteLimit)
-    val actionInvokeSystemOverloadLimit = this(WhiskConfig.actionInvokeSystemOverloadDefaultLimit, WhiskConfig.actionInvokeSystemOverloadLimit)
-    val actionSequenceLimit = this(WhiskConfig.actionSequenceDefaultLimit)
+    val actionInvokePerMinuteLimit = this(WhiskConfig.actionInvokePerMinuteLimit)
+    val actionInvokeConcurrentLimit = this(WhiskConfig.actionInvokeConcurrentLimit)
+    val triggerFirePerMinuteLimit = this(WhiskConfig.triggerFirePerMinuteLimit)
+    val actionInvokeSystemOverloadLimit = this(WhiskConfig.actionInvokeSystemOverloadLimit)
+    val actionSequenceLimit = this(WhiskConfig.actionSequenceMaxLimit)
 }
 
 object WhiskConfig {
@@ -214,11 +214,7 @@ object WhiskConfig {
 
     val runtimesManifest = "runtimes.manifest"
 
-    val actionInvokePerMinuteDefaultLimit = "defaultLimits.actions.invokes.perMinute"
-    val actionInvokeConcurrentDefaultLimit = "defaultLimits.actions.invokes.concurrent"
-    val actionInvokeSystemOverloadDefaultLimit = "defaultLimits.actions.invokes.concurrentInSystem"
-    val triggerFirePerMinuteDefaultLimit = "defaultLimits.triggers.fires.perMinute"
-    val actionSequenceDefaultLimit = "defaultLimits.actions.sequence.maxLength"
+    val actionSequenceMaxLimit = "limits.actions.sequence.maxLength"
     val actionInvokePerMinuteLimit = "limits.actions.invokes.perMinute"
     val actionInvokeConcurrentLimit = "limits.actions.invokes.concurrent"
     val actionInvokeSystemOverloadLimit = "limits.actions.invokes.concurrentInSystem"
diff --git a/core/controller/src/main/scala/whisk/core/controller/Actions.scala b/core/controller/src/main/scala/whisk/core/controller/Actions.scala
index e7d812c..fc042a7 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Actions.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Actions.scala
@@ -57,7 +57,7 @@ import whisk.core.entitlement.Privilege._
  * in order to implement the actions API.
  */
 object WhiskActionsApi {
-    def requiredProperties = Map(WhiskConfig.actionSequenceDefaultLimit -> null)
+    def requiredProperties = Map(WhiskConfig.actionSequenceMaxLimit -> null)
 
     /** Grace period after action timeout limit to poll for result. */
     protected[core] val blockingInvokeGrace = 5 seconds
diff --git a/core/controller/src/main/scala/whisk/core/controller/Controller.scala b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
index ac99db8..90d4023 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Controller.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
@@ -145,8 +145,6 @@ object Controller {
         LoadBalancerService.requiredProperties ++
         EntitlementProvider.requiredProperties
 
-    def optionalProperties = EntitlementProvider.optionalProperties
-
     private def info(config: WhiskConfig, runtimes: Runtimes, apis: List[String]) = JsObject(
         "description" -> "OpenWhisk".toJson,
         "support" -> JsObject(
@@ -164,7 +162,7 @@ object Controller {
         implicit val logger = new AkkaLogging(akka.event.Logging.getLogger(actorSystem, this))
 
         // extract configuration data from the environment
-        val config = new WhiskConfig(requiredProperties, optionalProperties)
+        val config = new WhiskConfig(requiredProperties)
         val port = config.servicePort.toInt
 
         // if deploying multiple instances (scale out), must pass the instance number as the
diff --git a/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala b/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
index aa5d634..0bf2abb 100644
--- a/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
+++ b/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
@@ -61,17 +61,12 @@ protected[core] case class Resource(
 }
 
 protected[core] object EntitlementProvider {
-    val requiredProperties = Map(
-        WhiskConfig.actionInvokePerMinuteDefaultLimit -> null,
-        WhiskConfig.actionInvokeConcurrentDefaultLimit -> null,
-        WhiskConfig.triggerFirePerMinuteDefaultLimit -> null,
-        WhiskConfig.actionInvokeSystemOverloadDefaultLimit -> null)
 
-    val optionalProperties = Set(
-        WhiskConfig.actionInvokePerMinuteLimit,
-        WhiskConfig.actionInvokeConcurrentLimit,
-        WhiskConfig.triggerFirePerMinuteLimit,
-        WhiskConfig.actionInvokeSystemOverloadLimit)
+    val requiredProperties = Map(
+        WhiskConfig.actionInvokePerMinuteLimit -> null,
+        WhiskConfig.actionInvokeConcurrentLimit -> null,
+        WhiskConfig.triggerFirePerMinuteLimit -> null,
+        WhiskConfig.actionInvokeSystemOverloadLimit -> null)
 }
 
 /**
diff --git a/tests/src/test/scala/common/WhiskProperties.java b/tests/src/test/scala/common/WhiskProperties.java
index c713d43..915ed6a 100644
--- a/tests/src/test/scala/common/WhiskProperties.java
+++ b/tests/src/test/scala/common/WhiskProperties.java
@@ -244,9 +244,6 @@ public class WhiskProperties {
 
     public static int getMaxActionInvokesPerMinute() {
         String valStr = whiskProperties.getProperty("limits.actions.invokes.perMinute");
-        if (null == valStr) {
-            valStr = whiskProperties.getProperty("defaultLimits.actions.invokes.perMinute");
-        }
         return Integer.parseInt(valStr);
     }
 
diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index 0049f8b..0282f61 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -23,7 +23,6 @@ import scala.collection.parallel.immutable.ParSeq
 import scala.concurrent.Future
 import scala.concurrent.Promise
 import scala.concurrent.duration._
-import scala.util.Try
 
 import org.junit.runner.RunWith
 import org.scalatest.FlatSpec
@@ -66,22 +65,18 @@ class ThrottleTests
 
     val throttleWindow = 1.minute
 
-    val maximumInvokesPerMinute = getLimit("defaultLimits.actions.invokes.perMinute", "limits.actions.invokes.perMinute")
-    val maximumFiringsPerMinute = getLimit("defaultLimits.triggers.fires.perMinute", "limits.triggers.fires.perMinute")
-    val maximumConcurrentInvokes = getLimit("defaultLimits.actions.invokes.concurrent", "limits.actions.invokes.concurrent")
+    val maximumInvokesPerMinute = getLimit("limits.actions.invokes.perMinute")
+    val maximumFiringsPerMinute = getLimit("limits.triggers.fires.perMinute")
+    val maximumConcurrentInvokes = getLimit("limits.actions.invokes.concurrent")
 
     println(s"maximumInvokesPerMinute  = $maximumInvokesPerMinute")
     println(s"maximumFiringsPerMinute  = $maximumFiringsPerMinute")
     println(s"maximumConcurrentInvokes = $maximumConcurrentInvokes")
 
     /*
-     * Retrieve a numeric limit for the key from the property set.  If the overrideKey is present, use that.
+     * Retrieve a numeric limit for the key from the property set.
      */
-    def getLimit(key: String, overrideKey: String) = Try {
-        WhiskProperties.getProperty(overrideKey).toInt
-    } getOrElse {
-        WhiskProperties.getProperty(key).toInt
-    }
+    def getLimit(key: String) = WhiskProperties.getProperty(key).toInt
 
     /**
      * Extracts the number of throttled results from a sequence of <code>RunResult</code>
diff --git a/tests/src/test/scala/system/basic/WskSequenceTests.scala b/tests/src/test/scala/system/basic/WskSequenceTests.scala
index 906bfbb..452b776 100644
--- a/tests/src/test/scala/system/basic/WskSequenceTests.scala
+++ b/tests/src/test/scala/system/basic/WskSequenceTests.scala
@@ -59,7 +59,7 @@ class WskSequenceTests
     val allowedActionDuration = 120 seconds
     val shortDuration = 10 seconds
 
-    val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceDefaultLimit -> null))
+    val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit -> null))
     assert(whiskConfig.isValid)
 
     behavior of "Wsk Sequence"

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].