-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Provide action limit configuration for each namespace #5229
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
Conversation
Nice! |
Codecov Report
@@ Coverage Diff @@
## master #5229 +/- ##
=======================================
Coverage 81.12% 81.12%
=======================================
Files 239 239
Lines 14192 14192
Branches 580 580
=======================================
Hits 11513 11513
Misses 2679 2679 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
common/scala/src/main/scala/org/apache/openwhisk/core/entity/ConcurrencyLimit.scala
Outdated
Show resolved
Hide resolved
@@ -179,6 +178,8 @@ class InvokerReactive( | |||
WhiskAction | |||
.get(entityStore, actionid.id, actionid.rev, fromCache = actionid.rev != DocRevision.empty) | |||
.flatMap(action => { | |||
// action that exceed the system limit cannot be executed. | |||
action.limits.checkSystemLimits() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it already check the limit here? https://github.com/apache/openwhisk/pull/5229/files#diff-618ee3b5632d322d90e279346bd69b1d30f39f22b237e557f1a4f507414b61fdR216
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiangpengcheng The code you shared is for checking the limit when creating an action.
In order to prevent execution by malicious modifications such as DB alteration, the invoker side verifies once more before invoking an action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it apply the new scheduler? e.g. when FunctionPoolConatinerProxy fetches the activation from memoryQueue's activation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It supports new scheduler.
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
Outdated
Show resolved
Hide resolved
Messages.sizeExceedsAllowedThreshold(MemoryLimit.memoryLimitFieldName, is.toMB.toInt, allowed.toMB.toInt) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with test case, can provide the opposite test case? e.g. allow create when memory is greater than maximum allowed namespace limit?
@@ -624,6 +626,30 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with | |||
}) | |||
} | |||
|
|||
private def checkNamespaceAndSystemLimits(user: Identity, content: WhiskActionPut)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be two separate functions? The context in which you check the set limits for a namespace are different from the context you check the system limits. You check against the system limits when creating the action or updating your namespace's configuration. When you check against the namespace's limit it would be on the execution path when an activation is occurring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because updating the namespace limit configuration directly inserts/updates into the Couch DB, I've updated the code to fallback to the system limit if the namespace limit that exceeds the system limit.
So, namespace limits that can not exceed the system limit are checked when an action is created/invoked.
@style95 As the implementation continues to change, POEM has been added to this PR for consistency.
|
According to this process, we need a separate PR to add a POEM along with this PR. |
If this pr: /pull/5229 merged. Let's assume, user may want to use 3GB of memory for her action, but the system limit maybe 2GB currently.
Have any influence for old action? e.g. user or admin may need some migration works. |
I'm working on integrating with the new scheduler and improving backward compatibility. I'ill create a separate POEM PR as soon as it is completed. |
Removed the POEM document file from this PR as it created a separate PR for POEM #5236. |
7de6e59
to
ac42477
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It generally looks good to me.
common/scala/src/main/scala/org/apache/openwhisk/core/containerpool/AkkaContainerClient.scala
Show resolved
Hide resolved
@@ -124,13 +129,13 @@ protected class ApacheBlockingContainerClient(hostname: String, | |||
|
|||
// Negative contentLength means unknown or overflow. We don't want to consume in either case. | |||
if (contentLength >= 0) { | |||
if (contentLength <= maxResponseBytes) { | |||
if (contentLength <= maxResponse.toBytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need toBytes
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Since maxResponse is a ByteSize type, it needs a cast.
maxResponse: ByteSize,
} catch { | ||
case _: Throwable => | ||
// Supports backwards compatibility for openwhisk that do not use the namespace default limit | ||
ActivationEntityPayload(config.payload.max, config.payload.truncation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
val int = the[DeserializationException] thrownBy s.read(JsNumber(2.5)) | ||
int.getMessage should include("limit must be whole number") | ||
} | ||
} | ||
} | ||
|
||
it should "reject bad limit values" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need this negative test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scheme test based on the hardcoded limit value is no longer used and validation checks are performed based on user input at runtime.
@upgle It seems it does not pass the unit test. |
8b343d9
to
4222ceb
Compare
4222ceb
to
5442831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
ea4930b
to
fa46215
Compare
Need rebase |
0a312a4
to
0fbc5e8
Compare
8881b5e
to
28ade66
Compare
merged as it's been so long. |
Description
Currently, openwhisk has only the system limit shared by all namespaces. I have received requirements to set different limits for each namespace/user. So I propose a new feature for namespace limit.
3 types of limits
case1) Using default namespace limit

case1) Using namespace limit (for

foo
namespace)Limit doc
You can set namespace limits with
{namespace}/limits
document just like any other existing setting.New namespace limit config
Related issue and scope
I didn't open new issue, but described the changes here.
My changes affect the following components
Types of changes
Checklist: