Skip to content

impr(CLDSRV-852): Refactor WorkerTokenBucket#6108

Open
tmacro wants to merge 13 commits intoimprovement/CLDSRV-852/refactor_cachefrom
improvement/CLDSRV-852/refactor_token_bucket_2
Open

impr(CLDSRV-852): Refactor WorkerTokenBucket#6108
tmacro wants to merge 13 commits intoimprovement/CLDSRV-852/refactor_cachefrom
improvement/CLDSRV-852/refactor_token_bucket_2

Conversation

@tmacro
Copy link
Contributor

@tmacro tmacro commented Mar 13, 2026

  • Update RateLimitClient.grantToken() params
  • Cleanup calculateInterval helper
  • Refactor WorkerTokenBucket
    • Change constructor to accept resourceClass, resourceId, measure
    • Precalculate interval for reuse in constructor
    • Add hasCapacity() method
    • Add updateLimit() method to encasulate limit change logic
    • Remove unused mechanism to record request durations
    • Simplify refill logic

Note for revewers: S3 API unit tests are still expected to fail

@codecov
Copy link

codecov bot commented Mar 13, 2026

❌ 105 Tests Failed:

Tests completed Failed Passed Skipped
2695 105 2590 0
View the top 3 failed test(s) by shortest run time
should abort a multipart upload on real AWS location withbucketMatch set to false::Multipart Upload API with AWS Backend should abort a multipart upload on real AWS location withbucketMatch set to false
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should abort a multipart upload on real AWS::Multipart Upload API with AWS Backend should abort a multipart upload on real AWS
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should be successful initiating MPU on AWS with Scality S3 versioning enabled::Multipart Upload API with AWS Backend should be successful initiating MPU on AWS with Scality S3 versioning enabled
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should complete a multipart upload on real AWS location with bucketMatch set to false::Multipart Upload API with AWS Backend should complete a multipart upload on real AWS location with bucketMatch set to false
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should complete a multipart upload on real AWS::Multipart Upload API with AWS Backend should complete a multipart upload on real AWS
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should complete a multipart upload::Multipart Upload API with AWS Backend with mpu initiated on legacy version should complete a multipart upload
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should copy part to AWS based on mpu location::ObjectCopyPutPart API with multiple backends should copy part to AWS based on mpu location
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should copy part to file based on request endpoint::ObjectCopyPutPart API with multiple backends should copy part to file based on request endpoint
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should initiate a multipart upload on AWS location with bucketMatch equals false::Multipart Upload API with AWS Backend should initiate a multipart upload on AWS location with bucketMatch equals false
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should initiate a multipart upload with tags on AWS::Multipart Upload API with AWS Backend should initiate a multipart upload with tags on AWS
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should list all multipart uploads on all backends::Multipart Upload API with AWS Backend should list all multipart uploads on all backends
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should list the parts of a multipart upload on real AWS::Multipart Upload API with AWS Backend should list the parts of a multipart upload on real AWS
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should only list parts after PartNumberMarker::Multipart Upload API with AWS Backend should only list parts after PartNumberMarker
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should only return number of parts equal to specified maxParts::Multipart Upload API with AWS Backend should only return number of parts equal to specified maxParts
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put a part to AWS based on mpu location::objectPutPart API with multiple backends should put a part to AWS based on mpu location
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put a part to file based on request endpoint::objectPutPart API with multiple backends should put a part to file based on request endpoint
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put an object to AWS::objectPutAPI with multiple backends should put an object to AWS
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put an object to file based on bucket location::objectPutAPI with multiple backends should put an object to file based on bucket location
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put an object to file::objectPutAPI with multiple backends should put an object to file
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should put an object to us-east-1 which is file based on bucket location if no locationConstraint provided::objectPutAPI with multiple backends should put an object to us-east-1 which is file based on bucket location if no locationConstraint provided
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return ServiceUnavailable if MPU deleted directly from AWS and try to complete from S3::Multipart Upload API with AWS Backend should return ServiceUnavailable if MPU deleted directly from AWS and try to complete from S3
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return an error on listParts of deleted MPU::Multipart Upload API with AWS Backend should return an error on listParts of deleted MPU
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return entityTooSmall error::Multipart Upload API with AWS Backend should return entityTooSmall error
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return error on abort of MPU that does not exist::Multipart Upload API with AWS Backend should return error on abort of MPU that does not exist
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return invalidPart error::Multipart Upload API with AWS Backend should return invalidPart error
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should return invalidPartOrder error::Multipart Upload API with AWS Backend should return invalidPartOrder error
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
should store a part even if the MPU was initiated on legacy version::objectPutPart API with multiple backends should store a part even if the MPU was initiated on legacy version
Stack Traces | 0s run time
extractAndCacheRateLimitConfig is not a function
"after each" hook for "DELETE .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should delete the XML file"::Veeam routes: veeam DELETE routes: "after each" hook for "DELETE .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should delete the XML file"
Stack Traces | 0.001s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"after each" hook for "GET .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the expected XML file"::Veeam routes: veeam GET routes: "after each" hook for "GET .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the expected XML file"
Stack Traces | 0.001s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"after each" hook for "HEAD .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the existing XML file metadata"::Veeam routes: veeam HEAD routes: "after each" hook for "HEAD .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the existing XML file metadata"
Stack Traces | 0.001s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before each" hook for "should successfully replicate a version"::backbeat routes for replication (cross account) "before each" hook for "should successfully replicate a version"
Stack Traces | 0.001s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before each" hook for "should successfully replicate a version"::backbeat routes for replication (same account) "before each" hook for "should successfully replicate a version"
Stack Traces | 0.001s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should abort a multipart upload::Multipart Upload API with AWS Backend with mpu initiated on legacy version should abort a multipart upload
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should allow creating mpu with SSE header in encrypted bucket::KMIP backed server-side encryption should allow creating mpu with SSE header in encrypted bucket
Stack Traces | 0.001s run time
connect ECONNREFUSED 127.0.0.1:8000
should allow object PUT with SSE header in encrypted bucket::KMIP backed server-side encryption should allow object PUT with SSE header in encrypted bucket
Stack Traces | 0.001s run time
connect ECONNREFUSED 127.0.0.1:8000
should allow object copy with SSE header in encrypted bucket::KMIP backed server-side encryption should allow object copy with SSE header in encrypted bucket
Stack Traces | 0.001s run time
connect ECONNREFUSED 127.0.0.1:8000
should allow writes after deleting data with quotas below the current number of inflights::quota evaluation with scuba metrics should allow writes after deleting data with quotas below the current number of inflights
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should complete MPU on AWS with same key as object put to file::Multipart Upload API with AWS Backend should complete MPU on AWS with same key as object put to file
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should complete MPU on file with same key as object put to AWS::Multipart Upload API with AWS Backend should complete MPU on file with same key as object put to AWS
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy an object as a part to a multipart upload::Multipart Upload API with AWS Backend with mpu initiated on legacy version should copy an object as a part to a multipart upload
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part an object on AWS location that has bucketMatch equals false to a mpu with a different AWS location::ObjectCopyPutPart API with multiple backends should copy part an object on AWS location that has bucketMatch equals false to a mpu with a different AWS location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part an object on AWS to a mpu with a different AWS location that has bucketMatch equals false::ObjectCopyPutPart API with multiple backends should copy part an object on AWS to a mpu with a different AWS location that has bucketMatch equals false
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part to AWS based on bucket location::ObjectCopyPutPart API with multiple backends should copy part to AWS based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part to file based on bucket location::ObjectCopyPutPart API with multiple backends should copy part to file based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part to file based on mpu location::ObjectCopyPutPart API with multiple backends should copy part to file based on mpu location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part to mem based on bucket location::ObjectCopyPutPart API with multiple backends should copy part to mem based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should copy part to mem from AWS based on mpu location::ObjectCopyPutPart API with multiple backends should copy part to mem from AWS based on mpu location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should decrease the inflights when performing multi object delete::quota evaluation with scuba metrics should decrease the inflights when performing multi object delete
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should initiate a multipart upload on real AWS::Multipart Upload API with AWS Backend should initiate a multipart upload on real AWS
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should list multipart upload parts::Multipart Upload API with AWS Backend with mpu initiated on legacy version should list multipart upload parts
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should list the parts of a multipart upload on real AWS location with bucketMatch set to false::Multipart Upload API with AWS Backend should list the parts of a multipart upload on real AWS location with bucketMatch set to false
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should not increase the inflights when the object is being rewritten with a smaller object::quota evaluation with scuba metrics should not increase the inflights when the object is being rewritten with a smaller object
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should not update the inflights if the API errored after evaluating quotas (deletion)::quota evaluation with scuba metrics should not update the inflights if the API errored after evaluating quotas (deletion)
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should only evaluate quota and not update inflights for PutObject with the x-scal-s3-version-id header::quota evaluation with scuba metrics should only evaluate quota and not update inflights for PutObject with the x-scal-s3-version-id header
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should put a part to AWS based on bucket location with bucketMatch set to false::objectPutPart API with multiple backends should put a part to AWS based on bucket location with bucketMatch set to false
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put a part to AWS based on bucket location with bucketMatch set to true::objectPutPart API with multiple backends should put a part to AWS based on bucket location with bucketMatch set to true
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put a part to AWS based on bucket location::objectPutPart API with multiple backends should put a part to AWS based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put a part to file based on bucket location::objectPutPart API with multiple backends should put a part to file based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put a part to mem based on bucket location::objectPutPart API with multiple backends should put a part to mem based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to AWS based on bucket location::objectPutAPI with multiple backends should put an object to AWS based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to Azure based on bucket location::objectPutAPI with multiple backends should put an object to Azure based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to azure::objectPutAPI with multiple backends should put an object to azure
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to mem based on bucket location::objectPutAPI with multiple backends should put an object to mem based on bucket location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to mem::objectPutAPI with multiple backends should put an object to mem
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should put an object to sproxyd::objectPutAPI with multiple backends should put an object to sproxyd
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should reduce inflights when aborting MPU::quota evaluation with scuba metrics should reduce inflights when aborting MPU
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should reduce inflights when completing MPU with fewer parts than uploaded::quota evaluation with scuba metrics should reduce inflights when completing MPU with fewer parts than uploaded
Stack Traces | 0.001s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should replace part if two parts uploaded with same part number to AWS::objectPutPart API with multiple backends should replace part if two parts uploaded with same part number to AWS
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should upload a part to file based on mpu location::objectPutPart API with multiple backends should upload a part to file based on mpu location
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
should upload part based on mpu location even if part location constraint is specified ::objectPutPart API with multiple backends should upload part based on mpu location even if part location constraint is specified 
Stack Traces | 0.001s run time
extractAndCacheRateLimitConfig is not a function
"after all" hook for "PUT .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/capacity.xml should fail if invalid credentials are sent"::Veeam routes: veeam PUT routes: "after all" hook for "PUT .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/capacity.xml should fail if invalid credentials are sent"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"after each" hook for "should successfully replicate a version"::backbeat routes for replication (same account) "after each" hook for "should successfully replicate a version"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before all" hook for "PUT .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml"::Veeam routes: veeam PUT routes: "before all" hook for "PUT .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before each" hook for "DELETE .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should delete the XML file"::Veeam routes: veeam DELETE routes: "before each" hook for "DELETE .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should delete the XML file"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before each" hook for "GET .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the expected XML file"::Veeam routes: veeam GET routes: "before each" hook for "GET .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the expected XML file"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"before each" hook for "HEAD .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the existing XML file metadata"::Veeam routes: veeam HEAD routes: "before each" hook for "HEAD .system-d26a9498-cb7c-4a87-a44a-8ae204f5ba6c/system.xml should return the existing XML file metadata"
Stack Traces | 0.002s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
object metadata for newly stored object should have dataStoreName if copying to mem based on bucket location::ObjectCopy API with multiple backends object metadata for newly stored object should have dataStoreName if copying to mem based on bucket location
Stack Traces | 0.002s run time
extractAndCacheRateLimitConfig is not a function
should allow a restore if the quota is full but the objet fits with its reserved storage space::quota evaluation with scuba metrics should allow a restore if the quota is full but the objet fits with its reserved storage space
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should allow writes after deleting data with quotas::quota evaluation with scuba metrics should allow writes after deleting data with quotas
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should allow writes after multi-deleting data with quotas below the current number of inflights::quota evaluation with scuba metrics should allow writes after multi-deleting data with quotas below the current number of inflights
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should copy part to mem based on mpu location::ObjectCopyPutPart API with multiple backends should copy part to mem based on mpu location
Stack Traces | 0.002s run time
extractAndCacheRateLimitConfig is not a function
should create an encrypted bucket and upload an object::KMIP backed server-side encryption should create an encrypted bucket and upload an object
Stack Traces | 0.002s run time
connect ECONNREFUSED 127.0.0.1:8000
should not evaluate quotas if the backend is not available::quota evaluation with scuba metrics should not evaluate quotas if the backend is not available
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should not return QuotaExceeded if the quota is not exceeded::quota evaluation with scuba metrics should not return QuotaExceeded if the quota is not exceeded
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return QuotaExceeded when trying to CopyObject in a bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to CopyObject in a bucket with quota
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return QuotaExceeded when trying to complete MPU in a bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to complete MPU in a bucket with quota
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return QuotaExceeded when trying to copy a part in a bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to copy a part in a bucket with quota
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return QuotaExceeded when trying to restore an object in a bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to restore an object in a bucket with quota
Stack Traces | 0.002s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should not update the inflights if the quota check is passing but the object is already restored::quota evaluation with scuba metrics should not update the inflights if the quota check is passing but the object is already restored
Stack Traces | 0.003s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return QuotaExceeded when trying to copyObject in a versioned bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to copyObject in a versioned bucket with quota
Stack Traces | 0.003s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
"after each" hook for "should successfully replicate a version"::backbeat routes for replication (cross account) "after each" hook for "should successfully replicate a version"
Stack Traces | 0.004s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should put a part to mem based on mpu location::objectPutPart API with multiple backends should put a part to mem based on mpu location
Stack Traces | 0.004s run time
extractAndCacheRateLimitConfig is not a function
"after all" hook in "backbeat routes"::backbeat routes "after all" hook in "backbeat routes"
Stack Traces | 0.007s run time
Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should return MethodNotAllowed for invalid request::Veeam routes: veeam invalid requests: should return MethodNotAllowed for invalid request
Stack Traces | 0.009s run time
Cannot read properties of undefined (reading 'statusCode')
should return QuotaExceeded when trying to PutObject in a bucket with quota::quota evaluation with scuba metrics should return QuotaExceeded when trying to PutObject in a bucket with quota
Stack Traces | 0.089s run time
ifError got unwanted exception: socket hang up
should create an encrypted bucket::KMIP backed server-side encryption should create an encrypted bucket
Stack Traces | 0.1s run time
socket hang up
"before all" hook in "backbeat routes"::backbeat routes "before all" hook in "backbeat routes"
Stack Traces | 0.114s run time
read ECONNRESET
should set metrics for multipartUpload overwrite in a versioned bucket::utapi v2 metrics incoming and outgoing bytes should set metrics for multipartUpload overwrite in a versioned bucket
Stack Traces | 0.182s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for putObject and deleteObject::utapi v2 metrics incoming and outgoing bytes should set metrics for putObject and deleteObject
Stack Traces | 0.206s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for multiPartUpload overwrite::utapi v2 metrics incoming and outgoing bytes should set metrics for multiPartUpload overwrite
Stack Traces | 0.219s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for getObject::utapi v2 metrics incoming and outgoing bytes should set metrics for getObject
Stack Traces | 0.297s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics in versioned bucket::utapi v2 metrics incoming and outgoing bytes should set metrics in versioned bucket
Stack Traces | 0.305s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should not push a metric for a filtered bucket::utapi v2 metrics incoming and outgoing bytes should not push a metric for a filtered bucket
Stack Traces | 0.346s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for multiPartUpload::utapi v2 metrics incoming and outgoing bytes should set metrics for multiPartUpload
Stack Traces | 0.419s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for multipartUpload in a versioned bucket::utapi v2 metrics incoming and outgoing bytes should set metrics for multipartUpload in a versioned bucket
Stack Traces | 0.419s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for multiObjectDelete::utapi v2 metrics incoming and outgoing bytes should set metrics for multiObjectDelete
Stack Traces | 0.429s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for multiObjectDelete in a versioned bucket::utapi v2 metrics incoming and outgoing bytes should set metrics for multiObjectDelete in a versioned bucket
Stack Traces | 0.461s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for copyObject::utapi v2 metrics incoming and outgoing bytes should set metrics for copyObject
Stack Traces | 0.553s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.
should set metrics for createBucket and deleteBucket::utapi v2 metrics incoming and outgoing bytes should set metrics for createBucket and deleteBucket
Stack Traces | 0.6s run time
ifError got unwanted exception: Inaccessible host: `127.0.0.1' at port `8000'. This service may not be available in the `us-east-1' region.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@scality scality deleted a comment from claude bot Mar 13, 2026
@scality scality deleted a comment from claude bot Mar 13, 2026
@tmacro tmacro force-pushed the improvement/CLDSRV-852/refactor_token_bucket_2 branch from 446cb3b to ee952c3 Compare March 13, 2026 14:41
@scality scality deleted a comment from claude bot Mar 13, 2026
@claude
Copy link

claude bot commented Mar 13, 2026

LGTM

The refactoring is clean and consistent:
- grantTokens() signature correctly updated from bucketName to resourceClass, resourceId, measure across client, tokenBucket, and all callers/tests.
- calculateInterval simplified from (limit, nodes, workers) to (limit, nodes) with consistent usage.
- WorkerTokenBucket constructor, hasCapacity(), and updateLimit() are straightforward. refillInProgress guard and finally cleanup are correct.
- Tests properly cover the new constructor params, hasCapacity(), updateLimit(), cache key format, and resource class separation.
- No async error handling issues, no double callbacks, no security concerns.

Review by Claude Code

@tmacro tmacro force-pushed the improvement/CLDSRV-852/refactor_cache branch from 4b83cef to b40ff80 Compare March 18, 2026 20:47
tmacro added 7 commits March 18, 2026 13:50
- Change constructor to accept resourceClass, resourceId, measure
- Precalculate interval for reuse in constructor
- Add hasCapacity() method
- Add updateLimit() method to encasulate limit change logic
- Remove unused mechanism to record request durations
- Simplify refill logic
@tmacro tmacro force-pushed the improvement/CLDSRV-852/refactor_token_bucket_2 branch from ee952c3 to a68c32e Compare March 18, 2026 20:50
// Per-node rate = limit / nodes (workers NOT divided)
// This allows dynamic work-stealing - workers evaluate at node quota

function calculateInterval(limit, nodes) {
Copy link

Choose a reason for hiding this comment

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

calculateInterval now accepts only 2 params (limit, nodes) — the workers param was removed. However, lib/api/apiUtils/rateLimit/config.js:232 still calls calculateInterval(limit, nodes, clusters) with 3 args. The third arg is silently ignored, so the interval no longer accounts for worker count. If intentional, config.js needs its comments and validation message updated. If not, this is a rate limiting bug.

— Claude Code

* Examples:
* - 100 req/s ÷ 1 node ÷ 10 workers = 10 req/s per worker → interval = 100ms
* - 600 req/s ÷ 6 nodes ÷ 10 workers = 10 req/s per worker → interval = 100ms
* - 100 req/s ÷ 1 node = 100 req/s per node → interval = 100ms
Copy link

Choose a reason for hiding this comment

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

The examples are incorrect after removing the workers divisor. 100 req/s ÷ 1 node = 100 req/s per node → interval = 1000/100 = 10ms, not 100ms. Similarly 600 req/s ÷ 6 nodes = 100 req/s per node → interval = 10ms, not 100ms. These values were correct when workers (10) was part of the formula but weren't updated.

— Claude Code

@claude
Copy link

claude bot commented Mar 18, 2026

  • lib/api/apiUtils/rateLimit/config.js:232 calls calculateInterval(limit, nodes, clusters) with 3 args, but the refactored function now only accepts 2 (limit, nodes). The clusters arg is silently ignored. The comments and validation message in config.js (lines 217-224, 231) still reference "nodes x workers" and "per-worker" semantics and need updating to match.
  • lib/api/apiUtils/rateLimit/gcra.js comment examples (lines 13-14) still show interval = 100ms for 100 req/s on 1 node, but the correct value with the new formula is 1000/100 = 10ms. The old value was correct when workers (10) was part of the division.

Review by Claude Code

@tmacro tmacro force-pushed the improvement/CLDSRV-852/refactor_cache branch from b40ff80 to 100976b Compare March 19, 2026 15:29
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.

1 participant