You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/11/16 15:43:49 UTC
[GitHub] tysonnorris closed pull request #383: enable use of concurrency
action limits via cli
tysonnorris closed pull request #383: enable use of concurrency action limits via cli
URL: https://github.com/apache/incubator-openwhisk-cli/pull/383
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/commands/action.go b/commands/action.go
index 4d0ad4e5..e6429bce 100644
--- a/commands/action.go
+++ b/commands/action.go
@@ -42,6 +42,7 @@ const (
MEMORY_LIMIT = 256
TIMEOUT_LIMIT = 60000
LOGSIZE_LIMIT = 10
+ CONCURRENCY_LIMIT = 1
ACTIVATION_ID = "activationId"
WEB_EXPORT_ANNOT = "web-export"
RAW_HTTP_ANNOT = "raw-http"
@@ -413,9 +414,11 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
cmd.LocalFlags().Changed(MEMORY_FLAG),
cmd.LocalFlags().Changed(LOG_SIZE_FLAG),
cmd.LocalFlags().Changed(TIMEOUT_FLAG),
+ cmd.LocalFlags().Changed(CONCURRENCY_FLAG),
Flags.action.memory,
Flags.action.logsize,
- Flags.action.timeout)
+ Flags.action.timeout,
+ Flags.action.concurrency)
paramArgs = Flags.common.param
annotArgs = Flags.common.annotation
@@ -886,10 +889,10 @@ func webSecureSecret(webSecureMode string) interface{} {
}
}
-func getLimits(memorySet bool, logSizeSet bool, timeoutSet bool, memory int, logSize int, timeout int) *whisk.Limits {
+func getLimits(memorySet bool, logSizeSet bool, timeoutSet bool, concurrencySet bool, memory int, logSize int, timeout int, concurrency int) *whisk.Limits {
var limits *whisk.Limits
- if memorySet || logSizeSet || timeoutSet {
+ if memorySet || logSizeSet || timeoutSet || concurrencySet {
limits = new(whisk.Limits)
if memorySet {
@@ -903,6 +906,10 @@ func getLimits(memorySet bool, logSizeSet bool, timeoutSet bool, memory int, log
if timeoutSet {
limits.Timeout = &timeout
}
+
+ if concurrencySet {
+ limits.Concurrency = &concurrency
+ }
}
return limits
@@ -1268,6 +1275,7 @@ func init() {
actionCreateCmd.Flags().IntVarP(&Flags.action.timeout, TIMEOUT_FLAG, "t", TIMEOUT_LIMIT, wski18n.T("the timeout `LIMIT` in milliseconds after which the action is terminated"))
actionCreateCmd.Flags().IntVarP(&Flags.action.memory, MEMORY_FLAG, "m", MEMORY_LIMIT, wski18n.T("the maximum memory `LIMIT` in MB for the action"))
actionCreateCmd.Flags().IntVarP(&Flags.action.logsize, LOG_SIZE_FLAG, "l", LOGSIZE_LIMIT, wski18n.T("the maximum log size `LIMIT` in MB for the action"))
+ actionCreateCmd.Flags().IntVarP(&Flags.action.concurrency, CONCURRENCY_FLAG, "c", CONCURRENCY_LIMIT, wski18n.T("the maximum intra-container concurrent activation `LIMIT` for the action"))
actionCreateCmd.Flags().StringSliceVarP(&Flags.common.annotation, "annotation", "a", nil, wski18n.T("annotation values in `KEY VALUE` format"))
actionCreateCmd.Flags().StringVarP(&Flags.common.annotFile, "annotation-file", "A", "", wski18n.T("`FILE` containing annotation values in JSON format"))
actionCreateCmd.Flags().StringSliceVarP(&Flags.common.param, "param", "p", nil, wski18n.T("parameter values in `KEY VALUE` format"))
@@ -1284,6 +1292,7 @@ func init() {
actionUpdateCmd.Flags().IntVarP(&Flags.action.timeout, TIMEOUT_FLAG, "t", TIMEOUT_LIMIT, wski18n.T("the timeout `LIMIT` in milliseconds after which the action is terminated"))
actionUpdateCmd.Flags().IntVarP(&Flags.action.memory, MEMORY_FLAG, "m", MEMORY_LIMIT, wski18n.T("the maximum memory `LIMIT` in MB for the action"))
actionUpdateCmd.Flags().IntVarP(&Flags.action.logsize, LOG_SIZE_FLAG, "l", LOGSIZE_LIMIT, wski18n.T("the maximum log size `LIMIT` in MB for the action"))
+ actionUpdateCmd.Flags().IntVarP(&Flags.action.concurrency, CONCURRENCY_FLAG, "c", CONCURRENCY_LIMIT, wski18n.T("the maximum intra-container concurrent activation `LIMIT` for the action"))
actionUpdateCmd.Flags().StringSliceVarP(&Flags.common.annotation, "annotation", "a", []string{}, wski18n.T("annotation values in `KEY VALUE` format"))
actionUpdateCmd.Flags().StringVarP(&Flags.common.annotFile, "annotation-file", "A", "", wski18n.T("`FILE` containing annotation values in JSON format"))
actionUpdateCmd.Flags().StringSliceVarP(&Flags.common.param, "param", "p", []string{}, wski18n.T("parameter values in `KEY VALUE` format"))
diff --git a/commands/flags.go b/commands/flags.go
index 223ccfe0..d9761d2c 100644
--- a/commands/flags.go
+++ b/commands/flags.go
@@ -26,13 +26,14 @@ import (
///////////
const (
- MEMORY_FLAG = "memory"
- LOG_SIZE_FLAG = "logsize"
- TIMEOUT_FLAG = "timeout"
- WEB_FLAG = "web"
- WEB_SECURE_FLAG = "web-secure"
- SAVE_FLAG = "save"
- SAVE_AS_FLAG = "save-as"
+ MEMORY_FLAG = "memory"
+ LOG_SIZE_FLAG = "logsize"
+ CONCURRENCY_FLAG = "concurrency"
+ TIMEOUT_FLAG = "timeout"
+ WEB_FLAG = "web"
+ WEB_SECURE_FLAG = "web-secure"
+ SAVE_FLAG = "save"
+ SAVE_AS_FLAG = "save-as"
)
var cliDebug = os.Getenv("WSK_CLI_DEBUG") // Useful for tracing init() code
@@ -130,21 +131,22 @@ type FlagsStruct struct {
}
type ActionFlags struct {
- docker string
- native bool
- copy bool
- web string
- websecure string
- sequence bool
- timeout int
- memory int
- logsize int
- result bool
- kind string
- main string
- url bool
- save bool
- saveAs string
+ docker string
+ native bool
+ copy bool
+ web string
+ websecure string
+ sequence bool
+ timeout int
+ memory int
+ logsize int
+ concurrency int
+ result bool
+ kind string
+ main string
+ url bool
+ save bool
+ saveAs string
}
func IsVerbose() bool {
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
index 5e441970..3acbe6e4 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
@@ -39,6 +39,7 @@ import common.WskTestHelpers
import spray.json.DefaultJsonProtocol._
import spray.json._
import org.apache.openwhisk.core.entity._
+import org.apache.openwhisk.core.entity.ConcurrencyLimit._
import org.apache.openwhisk.core.entity.LogLimit._
import org.apache.openwhisk.core.entity.MemoryLimit._
import org.apache.openwhisk.core.entity.TimeLimit._
@@ -390,6 +391,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
val memoryLimit = 512 MB
val logLimit = 1 MB
val timeLimit = 60 seconds
+ val concurrencyLimit = 500
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
action.create(
@@ -397,7 +399,8 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
Some(TestUtils.getTestActionFilename("helloAsync.js")),
memory = Some(memoryLimit),
timeout = Some(timeLimit),
- logsize = Some(logLimit))
+ logsize = Some(logLimit),
+ concurrency = Some(concurrencyLimit))
}
val run = wsk.action.invoke(name, Map("payload" -> "this is a test".toJson))
@@ -2041,12 +2044,14 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
def testLimit(timeout: Option[Duration] = None,
memory: Option[ByteSize] = None,
logs: Option[ByteSize] = None,
+ concurrency: Option[Int] = None,
ec: Int = SUCCESS_EXIT) = {
// Limits to assert, standard values if CLI omits certain values
val limits = JsObject(
"timeout" -> timeout.getOrElse(STD_DURATION).toMillis.toJson,
"memory" -> memory.getOrElse(stdMemory).toMB.toInt.toJson,
- "logs" -> logs.getOrElse(stdLogSize).toMB.toInt.toJson)
+ "logs" -> logs.getOrElse(stdLogSize).toMB.toInt.toJson,
+ "concurrency" -> concurrency.getOrElse(stdConcurrent).toJson)
val name = "ActionLimitTests" + Instant.now.toEpochMilli
val createResult =
@@ -2057,8 +2062,9 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
logsize = logs,
memory = memory,
timeout = timeout,
+ concurrency = concurrency,
expectedExitCode = DONTCARE_EXIT)
- withClue(s"create failed for parameters: timeout = $timeout, memory = $memory, logsize = $logs:") {
+ withClue(s"create failed for parameters: timeout = $timeout, memory = $memory, logsize = $logs, concurrency = $concurrency:") {
result.exitCode should be(ec)
}
result
@@ -2084,13 +2090,15 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
time <- Seq(None, Some(MIN_DURATION), Some(MAX_DURATION))
mem <- Seq(None, Some(minMemory), Some(maxMemory))
log <- Seq(None, Some(minLogSize), Some(maxLogSize))
- } testLimit(time, mem, log)
+ concurrency <- Seq(None, Some(minConcurrent), Some(maxConcurrent))
+ } testLimit(time, mem, log, concurrency)
// Assert that invalid permutation are rejected
- testLimit(Some(0.milliseconds), None, None, BAD_REQUEST)
- testLimit(Some(100.minutes), None, None, BAD_REQUEST)
- testLimit(None, Some(0.MB), None, BAD_REQUEST)
- testLimit(None, Some(32768.MB), None, BAD_REQUEST)
- testLimit(None, None, Some(32768.MB), BAD_REQUEST)
+ testLimit(Some(0.milliseconds), None, None, None, BAD_REQUEST)
+ testLimit(Some(100.minutes), None, None, None, BAD_REQUEST)
+ testLimit(None, Some(0.MB), None, None, BAD_REQUEST)
+ testLimit(None, Some(32768.MB), None, None, BAD_REQUEST)
+ testLimit(None, None, Some(32768.MB), None, BAD_REQUEST)
+ testLimit(None, None, None, Some(5000), BAD_REQUEST)
}
}
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 3e7024ec..a837d5e0 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -927,6 +927,10 @@
"id": "the maximum memory `LIMIT` in MB for the action",
"translation": "the maximum memory `LIMIT` in MB for the action"
},
+ {
+ "id": "the maximum intra-container concurrent activation `LIMIT` for the action",
+ "translation": "the maximum intra-container concurrent activation `LIMIT` for the action"
+ },
{
"id": "the maximum log size `LIMIT` in MB for the action",
"translation": "the maximum log size `LIMIT` in MB for the action"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services