Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for variability in Account Limits from various provider impls. #1048

Merged
merged 11 commits into from
Apr 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Account for variability in Account Limits from various provider impls.
  • Loading branch information
mrutkows committed Apr 5, 2019
commit 7ffa79178cc9edd9988c31b74ed3f50dddb387d4
8 changes: 4 additions & 4 deletions parsers/manifest_parser_test.go
Original file line number Diff line number Diff line change
@@ -993,11 +993,11 @@ func TestComposeActionsForLimits(t *testing.T) {
assert.Nil(t, err, fmt.Sprintf(TEST_ERROR_COMPOSE_ACTION_FAILURE, file))

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)
//} else
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)
} 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")
21 changes: 18 additions & 3 deletions utils/validation.go
Original file line number Diff line number Diff line change
@@ -140,7 +140,12 @@ func LimitsTimeoutValidation(timeout *int) bool {
if timeout == nil {
return true
}
if *timeout < 100 || *timeout > 600000 {
if *timeout < 100 {
// Do not allow invalid limit to be added to API
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_TIMEOUT))
return false;
}
if *timeout > 600000 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_TIMEOUT))
}
@@ -153,7 +158,12 @@ 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
}
if *memory > 2048 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_MEMORY_SIZE))
}
@@ -166,7 +176,12 @@ 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
}
if *logsize > 10 {
// Emit a warning, but allow to pass through to provider
wskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_LOG_SIZE))
}
Loading