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

Add limit to not store activations for a limitted namespace. #4234

Merged
merged 3 commits into from Jan 24, 2019

Conversation

cbickel
Copy link
Contributor

@cbickel cbickel commented Jan 23, 2019

With this PR, operators will be able to disable storing of activations into activations store.
The flag is implemented like the per-namespace-limits. It can be set with wskadmin.

This PR was the initial idea of #4078. In the meantime, the idea in the other PR changed, to implement a throttle instead of a switch. But as this is a completely new type of rate-limit (which does not only allow or deny requests) that's a bit bigger to implement. So I'll go with a staged approach here and implement it as switch first.
If someone needs a throttle instead of completely switching off the writes to the DB, this can be brought up again and the throttle can be built up on the solution we already have.

Related issue and scope

  • I opened an issue to propose and discuss this change (#????)

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

With this PR, operators will be able to disable storing of activations into activations store.
The flag is implemented like the per-namespace-limits. It can be set with wskadmin.

This PR was the initial idea of apache#4078. In the meantime, the idea in the other PR changed, to implement a throttle instead of a switch. But as this is a completely new type of rate-limit (which does not only allow or deny requests) that's a bit bigger to implement. So I'll go with a staged approach here and implement it as switch first.
If someone needs a throttle instead of completely switching off the writes to the DB, this can be brought up again and the throttle can be built up on the solution we already have.
Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! I like that this is moving into a UserLimit.

I agree on the staged approach here. A simple on/off switch is a great first step imo.

.map { activation =>
activationStore.store(activation, context)
}
if (user.limits.storeActivations.getOrElse(true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The true default is scattered throughout the codebase now. I'm wondering if there is a good way of centralizing that.

One way is to add a val/def to the UserLimits class, which defaults to true always.

The other way is to add a system "limit" which makes it possible to enable/disable this for the whole system, therefore acting as the default.

I realize though that the second approach might be a bigger undertaking. Maybe it's fine as-is and we're better off having the default at the actual caller side to later get rid off.

More generally speaking: We should think about building a more generalized cascading system for our limits. I envision something like this:

  1. Load the user-limits from the database
  2. Merge them with the system limits
  3. Pass the merged versions through the code (maybe as part of the identity class)

That'd help us in cases as those and potentially transforms all the Option to actual values before we hit the location of usage.

You can ignore this comment if you want to, just wanted to leave the thoughts here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like the idea of consolidating the defaults --- for this and other annotations we use.

@@ -569,7 +569,9 @@ protected[actions] trait PrimitiveActions {
}
}

activationStore.store(activation, context)(transid, notifier = None)
if (user.limits.storeActivations.getOrElse(true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we move this into the ActivationStore itself? The user's identity is available in there as well.

I guess the thought was to not do that, because then each store needs to make sure to implement this if? Can we instead maybe come up with a wrapper function for all activationStore.store calls that takes care of a general concern like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I introduced the method storeAfterCheck, to do exactly that in ActivationStore, independant of the implementation.

@@ -132,6 +132,8 @@ def parseArgs():
subcmd.add_argument('--firesPerMinute', help='trigger fires per minute allowed', type=int)
subcmd.add_argument('--concurrentInvocations', help='concurrent invocations allowed for this namespace', type=int)
subcmd.add_argument('--allowedKinds', help='list of runtime kinds allowed in this namespace', nargs='+', type=str)
subcmd.add_argument('--enableStoreActivations', help='enable storing of activations to datastore for this namespace', default=None, dest='storeActivations', action='store_true')
subcmd.add_argument('--disableStoreActivations', help='disable storing of activations to datastore for this namespace', default=None, dest='storeActivations', action='store_false')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about scriptability here: Would it be easier to just use a value storeActivations=true/false instead of two distinct flags? If I were to use wskadmin in a script, I much rather do wskadmin --storeActivations=$VALUE than replacing the whole flag if that makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can have another look on that one 👍

@codecov-io
Copy link

codecov-io commented Jan 23, 2019

Codecov Report

Merging #4234 into master will decrease coverage by 4.94%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4234      +/-   ##
==========================================
- Coverage   86.01%   81.06%   -4.95%     
==========================================
  Files         153      154       +1     
  Lines        7349     7358       +9     
  Branches      487      499      +12     
==========================================
- Hits         6321     5965     -356     
- Misses       1028     1393     +365
Impacted Files Coverage Δ
...isk/core/controller/actions/PrimitiveActions.scala 85.71% <100%> (ø) ⬆️
...la/org/apache/openwhisk/core/entity/Identity.scala 92.85% <100%> (ø) ⬆️
...apache/openwhisk/core/database/LimitsCommand.scala 98.5% <100%> (+0.14%) ⬆️
...rg/apache/openwhisk/core/controller/Triggers.scala 94.11% <100%> (ø) ⬆️
...hisk/core/controller/actions/SequenceActions.scala 92.1% <100%> (ø) ⬆️
...ache/openwhisk/core/database/ActivationStore.scala 100% <100%> (ø)
...pache/openwhisk/core/invoker/InvokerReactive.scala 81.3% <100%> (ø) ⬆️
...core/database/cosmosdb/RxObservableImplicits.scala 0% <0%> (-100%) ⬇️
...core/database/cosmosdb/CosmosDBArtifactStore.scala 0% <0%> (-95.6%) ⬇️
...sk/core/database/cosmosdb/CosmosDBViewMapper.scala 0% <0%> (-92.6%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2312b7d...fb8efdb. Read the comment docs.

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally LGTM. +1 for Markus' suggestions.

.map { activation =>
activationStore.store(activation, context)
}
if (user.limits.storeActivations.getOrElse(true)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like the idea of consolidating the defaults --- for this and other annotations we use.

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for reworking the default. 🙂

@markusthoemmes markusthoemmes merged commit f83a438 into apache:master Jan 24, 2019
@cbickel cbickel deleted the tdb branch January 24, 2019 12:16
BillZong pushed a commit to BillZong/openwhisk that referenced this pull request Nov 18, 2019
…4234)

Operators will be able to disable storing of activations into activations store.
The flag is implemented like the per-namespace-limits. It can be set with wskadmin.

This commit was the initial idea of apache#4078. In the meantime, the idea in the other PR changed, to implement a throttle instead of a switch. But as this is a completely new type of rate-limit (which does not only allow or deny requests) that's a bit bigger to implement. So I'll go with a staged approach here and implement it as switch first.
If someone needs a throttle instead of completely switching off the writes to the DB, this can be brought up again and the throttle can be built upon the solution we already have.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants