Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sandeep-paliwal
Copy link
Contributor

Stopgap fix to throttle State Store DB usage

Description

  • Add a service based deny list validation for TVM
  • TVM will fetch the deny list from denyListUrl ( if its set in params). Each service impl will process deny list in its own way to provide enough flexibility.
  • Deny list will be cached in memory to improve performance.
  • TVM will make sure not to use any deny list beyond its expiry.
  • Changed Cosmos DB token expiration to 10 mins. This will enable to throttle any excessive usage of State Store for a given Namespace

Related Issue

Motivation and Context

How Has This Been Tested?

Manual Testing against TVM deployment
unit tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

sandeep-paliwal and others added 5 commits August 23, 2022 23:04
TVM will fetch the deny list from denyListUrl if its set
Each service impl will have its own deny list processing to provide enough flexibility
Deny list will be cached in memory to improve performance. TVM will make sure not to use any deny list beyond its expiry.
Changed Cosmos DB token expiration to 10 mins. This will enable to throttle any excessive usage of State Store for a given Namespace
@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #61 (5a856e2) into master (98c6eb8) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #61   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          345       387   +42     
  Branches        28        37    +9     
=========================================
+ Hits           345       387   +42     
Impacted Files Coverage Δ
lib/Tvm.js 100.00% <100.00%> (ø)
lib/impl/AzureCosmosTvm.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@moritzraho moritzraho left a comment

Choose a reason for hiding this comment

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

The logic lgtm but I feel like we are rushing an abstraction over all services to support a denylist and I am not a fan of fetching the denylist file when calling the files or cdn tvm, although they don't implement denylist. Would it be acceptable to move the logic to the cosmos tvm file for now?

If we still want to go for the one fit all solution I would favor having an enable/disable denylist param for every endpoint. And have the processDenyList function be the same for all.

But I might have missed somethings, feel free to debate ;)

this._validationSchema = {
/// deployment params - should not be setable by request - deployed as final
expirationDuration: joi.number().integer().min(900).max(18000).required(),
expirationDuration: joi.number().integer().min(600).max(18000).required(),
Copy link
Member

Choose a reason for hiding this comment

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

Can we change this to be cosmos specific ? I don't remember exactly but maybe 900 was a minimum for aws s3 or azure blob, if not then it's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me check this. I don't think 10 mins would hit azure blob minimum, but I will reconfirm this.

Copy link
Member

Choose a reason for hiding this comment

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

sure also need to check for aws s3

@sandeep-paliwal
Copy link
Contributor Author

sandeep-paliwal commented Sep 5, 2022

The logic lgtm but I feel like we are rushing an abstraction over all services to support a denylist and I am not a fan of fetching the denylist file when calling the files or cdn tvm, although they don't implement denylist. Would it be acceptable to move the logic to the cosmos tvm file for now?

If we still want to go for the one fit all solution I would favor having an enable/disable denylist param for every endpoint. And have the processDenyList function be the same for all.

But I might have missed somethings, feel free to debate ;)

I feel there is no harm to have a generic solution rather than a very specific cosmos related fix. We can easily extend the same design for other services. And each service gets to decide how it processes its own denylist.
Coming to the question of denylist itself, right now thats the best option available for us. Its least intrusive and totally optional. Plus using the inMemory cache we make sure that we don't run into any performance issues.

@moritzraho
Copy link
Member

lgtm, thanks for the additional details.

@sandeep-paliwal sandeep-paliwal merged commit 1e14f62 into master Oct 31, 2022
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.

3 participants