Skip to content

Commit

Permalink
Account for variability in Account Limits from various provider impls. (
Browse files Browse the repository at this point in the history
#1048)

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.

* Account for variability in Account Limits from various provider impls.
  • Loading branch information
mrutkows authored and pritidesai committed Apr 5, 2019
1 parent 7d79fd7 commit fa006fc
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 88 deletions.
5 changes: 3 additions & 2 deletions parsers/manifest_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,10 @@ func TestComposeActionsForLimits(t *testing.T) {

for i := 0; i < len(actions); i++ {
if actions[i].Action.Name == "hello1" {
assert.Nil(t, actions[i].Action.Limits, "Expected limit section to be empty but got %s", actions[i].Action.Limits)
assert.NotNil(t, actions[i].Action.Limits, "Expected limit section to not be empty but found it empty")
assert.Equal(t, 600000, *actions[i].Action.Limits.Timeout, "Failed to get Timeout")
} else if actions[i].Action.Name == "hello2" {
assert.NotNil(t, actions[i].Action.Limits, "Expected limit section to be not empty but found it empty")
assert.NotNil(t, actions[i].Action.Limits, "Expected limit section to not be empty but found it empty")
assert.Equal(t, 180, *actions[i].Action.Limits.Timeout, "Failed to get Timeout")
assert.Equal(t, 128, *actions[i].Action.Limits.Memory, "Failed to get Memory")
assert.Equal(t, 1, *actions[i].Action.Limits.Logsize, "Failed to get Logsize")
Expand Down
104 changes: 53 additions & 51 deletions specification/html/spec_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,70 +202,72 @@ following file extensions are recognized and will be run on the latest version o
<html>
<table id="TABLE_LIMIT_KEYS">
<tr>
<th>Limit Keyname</th>
<th>Allowed values</th>
<th>Default value</th>
<th>Valid Range</th>
<th>Description</th>
</tr>
<tr>
<td>timeout</td>
<td>scalar-unit.time</td>
<td>60000 ms</td>
<td>[100 ms, 300000 ms]</td>
<td>The per-invocation Action timeout. Default unit is assumed to be milliseconds (ms).</td>
</tr>
<tr>
<tr>
<th>Limit Keyname</th>
<th>Type</th>
<th>Default value <sup><a href="#limit-notes">1</a></sup></th>
<th>Default Range <sup><a href="#limit-notes">2</a></sup></th>
<th>Description</th>
</tr>
<tr>
<td>codeSize</td>
<td>scalar-unit.size</td>
<td>48 MB</td>
<td>[1, 48] MB<sup><a href="#limit-notes">3</a></sup></td>
<td>The maximum size of the Action code.</td>
</tr>
<tr>
<td>concurrentActivations</td>
<td>integer</td>
<td>1000</td>
<td>[1, 1000] <sup><a href="#limit-notes">3</a></sup></td>
<td>The maximum number of concurrent Action activations allowed (per-namespace).</td>
</tr>
<tr>
<td>logSize</td>
<td>scalar-unit.size</td>
<td>10 MB</td>
<td>[0, 10] MB</td>
<td>The action log size. Default unit is assumed to be in megabytes (MB).</td>
</tr>
<tr>
<td>memorySize</td>
<td>scalar-unit.size</td>
<td>256 MB</td>
<td>[128 MB, 512 MB]</td>
<td>[128, 2048] MB</td>
<td>The per-Action memory. Default unit is assumed to be in megabytes (MB).</p>
</td>
</tr>
<tr>
<td>logSize</td>
</tr>
<tr>
<td>parameterSize</td>
<td>scalar-unit.size</td>
<td>10 MB</td>
<td>[0 MB, 10 MB]</td>
<td>The action log size. Default unit is assumed to be in megabytes (MB).</td>
</tr>
<tr>
<td>concurrentActivations</td>
<td>integer</td>
<td>1000</td>
<td><i>See description</i></td>
<td>The maximum number of concurrent Action activations allowed (per-namespace). <p><i>Note: This value is not changeable via APIs at this time.</i></p></td>
</tr>
<tr>
<td>5 MB</td>
<td>[0, 5] MB <sup><a href="#limit-notes">3, 4</a></sup></td>
<td>The maximum size of all parameters (total) for an Action.</td>
</tr>
<tr>
<td>timeout</td>
<td>scalar-unit.time</td>
<td>60000 ms</td>
<td>[100, 600000] ms</td>
<td>The per-invocation Action timeout. Default unit is assumed to be milliseconds (ms).</td>
</tr>
<tr>
<td>userInvocationRate</td>
<td>integer</td>
<td>5000</td>
<td><i>See description</i></td>
<td>The maximum number of Action invocations allowed per user, per minute. <p><i>Note: This value is not changeable via APIs at this time.</i></p></td>
</tr>
<tr>
<td>codeSize</td>
<td>scalar-unit.size</td>
<td>48 MB</td>
<td><i>See description</i></td>
<td>The maximum size of the Action code.<p><i>Note: This value is not changeable via APIs at this
time.</i></p></td>
</tr>
<tr>
<td>parameterSize</td>
<td>scalar-unit.size</td>
<td>1 MB</td>
<td><i>See description</i></td>
<td>The maximum size<p><i>Note: This value is not changeable via APIs at this time.</i></p></td>
</tr>
<td>[1, 5000] <sup><a href="#limit-notes">3</a></sup></td>
<td>The maximum number of Action invocations allowed per user, per minute.</td>
</tr>
</table>
</html>
#### Notes
#### Limit Notes
- The default values and ranges for limit configurations reflect the defaults for the OpenWhisk platform (open source code).&nbsp; These values may be changed over time to reflect the open source community consensus.
1. The default values and ranges for limit configurations reflect the defaults for the OpenWhisk platform (open source code).&nbsp; These values may be changed over time to reflect the open source community consensus.
2. Serverless providers that use Apache OpenWhisk MAY choose to enforce different defaults and value ranges for limits.
3. This limit is not currently user configurable.
4. The parameter size limit also applies to Triggers and Packages.
### Web Actions
OpenWhisk can turn any Action into a 'web action' causing it to return HTTP content without use of an API Gateway. Simply supply a supported 'type' extension to indicate which content type is to be returned and identified in the HTTP header (e.g., _.json_, _.html_, _.text_ or _.http_).
Expand Down
1 change: 1 addition & 0 deletions tests/dat/manifest_data_compose_actions_for_limits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ packages:
function: ../src/integration/helloworld/actions/hello.js
limits:
timeout: 1
timeout: 600000
hello2:
function: ../src/integration/helloworld/actions/hello.js
limits:
Expand Down
18 changes: 15 additions & 3 deletions utils/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ func LimitsTimeoutValidation(timeout *int) bool {
if timeout == nil {
return true
}
if *timeout < 100 || *timeout > 300000 {
if *timeout < 100 {
// Do not allow invalid limit to be added to API
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_TIMEOUT))
return false
} else if *timeout > 600000 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_TIMEOUT))
}
return true
}
Expand All @@ -153,9 +157,13 @@ func LimitsMemoryValidation(memory *int) bool {
if memory == nil {
return true
}
if *memory < 128 || *memory > 2048 {
if *memory < 128 {
// Do not allow invalid limit to be added to API
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_MEMORY_SIZE))
return false
} else if *memory > 2048 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_MEMORY_SIZE))
}
return true
}
Expand All @@ -166,9 +174,13 @@ func LimitsLogsizeValidation(logsize *int) bool {
if logsize == nil {
return true
}
if *logsize < 0 || *logsize > 10 {
if *logsize < 0 {
// Do not allow invalid limit to be added to API
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_LOG_SIZE))
return false
} else if *logsize > 10 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_LOG_SIZE))
}
return true
}
Expand Down
Loading

0 comments on commit fa006fc

Please sign in to comment.