From 360dd616ff14ee791ac6a5a325deb8e4403f9e4c Mon Sep 17 00:00:00 2001 From: Louis Ruch Date: Mon, 8 Jan 2024 23:24:40 -0800 Subject: [PATCH] fix(rate-limiting): Add support for Scope-StoragePolicy actions --- .../daemon/controller/rate_limiter_test.go | 2 +- .../defaults.json | 54 ++++++++++++++++++- .../max_size.json | 52 ++++++++++++++++++ .../override.json | 54 ++++++++++++++++++- 4 files changed, 159 insertions(+), 3 deletions(-) diff --git a/internal/daemon/controller/rate_limiter_test.go b/internal/daemon/controller/rate_limiter_test.go index f473410d5..cc44c1707 100644 --- a/internal/daemon/controller/rate_limiter_test.go +++ b/internal/daemon/controller/rate_limiter_test.go @@ -63,7 +63,7 @@ func Test_newRateLimiterConfig(t *testing.T) { ratelimit.DefaultLimiterMaxQuotas(), false, &rateLimiterConfig{ - maxSize: 308154, + maxSize: 312156, configs: nil, disabled: false, limits: defaultLimits, diff --git a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/defaults.json b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/defaults.json index 3f7984537..fed2725a8 100644 --- a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/defaults.json +++ b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/defaults.json @@ -2578,6 +2578,58 @@ "resource": "scope", "unlimited": false } + ], + "attach-storage-policy": [ + { + "action": "attach-storage-policy", + "limit": 30000, + "per": "total", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 30000, + "per": "ip-address", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 3000, + "per": "auth-token", + "period": "30s", + "resource": "scope", + "unlimited": false + } + ], + "detach-storage-policy": [ + { + "action": "detach-storage-policy", + "limit": 30000, + "per": "total", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 30000, + "per": "ip-address", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 3000, + "per": "auth-token", + "period": "30s", + "resource": "scope", + "unlimited": false + } ] }, "session": { @@ -3893,7 +3945,7 @@ ] } }, - "max_size": 308154, + "max_size": 312156, "msg": "controller api rate limiter" }, "op": "controller.(rateLimiterConfig).writeSysEvent", diff --git a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/max_size.json b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/max_size.json index 688578696..10ca1d798 100644 --- a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/max_size.json +++ b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/max_size.json @@ -2578,6 +2578,58 @@ "resource": "scope", "unlimited": false } + ], + "attach-storage-policy": [ + { + "action": "attach-storage-policy", + "limit": 30000, + "per": "total", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 30000, + "per": "ip-address", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 3000, + "per": "auth-token", + "period": "30s", + "resource": "scope", + "unlimited": false + } + ], + "detach-storage-policy": [ + { + "action": "detach-storage-policy", + "limit": 30000, + "per": "total", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 30000, + "per": "ip-address", + "period": "30s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 3000, + "per": "auth-token", + "period": "30s", + "resource": "scope", + "unlimited": false + } ] }, "session": { diff --git a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/override.json b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/override.json index 788d57e83..325b58313 100644 --- a/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/override.json +++ b/internal/daemon/controller/testdata/Test_rateLimiterConfig_writeSysEvent/override.json @@ -2578,6 +2578,58 @@ "resource": "scope", "unlimited": false } + ], + "attach-storage-policy": [ + { + "action": "attach-storage-policy", + "limit": 100, + "per": "total", + "period": "1m0s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 100, + "per": "ip-address", + "period": "1m0s", + "resource": "scope", + "unlimited": false + }, + { + "action": "attach-storage-policy", + "limit": 100, + "per": "auth-token", + "period": "1m0s", + "resource": "scope", + "unlimited": false + } + ], + "detach-storage-policy": [ + { + "action": "detach-storage-policy", + "limit": 100, + "per": "total", + "period": "1m0s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 100, + "per": "ip-address", + "period": "1m0s", + "resource": "scope", + "unlimited": false + }, + { + "action": "detach-storage-policy", + "limit": 100, + "per": "auth-token", + "period": "1m0s", + "resource": "scope", + "unlimited": false + } ] }, "session": { @@ -3893,7 +3945,7 @@ ] } }, - "max_size": 308154, + "max_size": 312156, "msg": "controller api rate limiter" }, "op": "controller.(rateLimiterConfig).writeSysEvent",