ratelimit: Support options for container access ratelimit
This change introduces support for the following two options which controls rate limit for container access. - container_ratelimit_<size> = <rate> - container_listing_ratelimit_<size> = <rate> Change-Id: Ibed7f31e9ad472ac490ac6a2933ffa2c8329f376
This commit is contained in:
@@ -27,6 +27,14 @@
|
||||
# (optional) if >0, limits PUT and DELETE requests to containers
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*container_ratelimit*]
|
||||
# (optional) Hash of size(keys) and requests per seconds(values).
|
||||
# Defaults to {}.
|
||||
#
|
||||
# [*container_listing_ratelimit*]
|
||||
# (optional) Hash of size(keys) and requests per seconds(values).
|
||||
# Defaults to {}.
|
||||
#
|
||||
# == Dependencies
|
||||
#
|
||||
# == Examples
|
||||
@@ -40,15 +48,20 @@
|
||||
# Copyright 2012 eNovance licensing@enovance.com
|
||||
#
|
||||
class swift::proxy::ratelimit(
|
||||
$clock_accuracy = $::os_service_default,
|
||||
$max_sleep_time_seconds = $::os_service_default,
|
||||
$log_sleep_time_seconds = $::os_service_default,
|
||||
$rate_buffer_seconds = $::os_service_default,
|
||||
$account_ratelimit = $::os_service_default
|
||||
$clock_accuracy = $::os_service_default,
|
||||
$max_sleep_time_seconds = $::os_service_default,
|
||||
$log_sleep_time_seconds = $::os_service_default,
|
||||
$rate_buffer_seconds = $::os_service_default,
|
||||
$account_ratelimit = $::os_service_default,
|
||||
$container_ratelimit = {},
|
||||
$container_listing_ratelimit = {},
|
||||
) {
|
||||
|
||||
include swift::deps
|
||||
|
||||
validate_legacy(Hash, 'validate_hash', $container_ratelimit)
|
||||
validate_legacy(Hash, 'validate_hash', $container_listing_ratelimit)
|
||||
|
||||
swift_proxy_config {
|
||||
'filter:ratelimit/use': value => 'egg:swift#ratelimit';
|
||||
'filter:ratelimit/clock_accuracy': value => $clock_accuracy;
|
||||
@@ -57,4 +70,16 @@ class swift::proxy::ratelimit(
|
||||
'filter:ratelimit/rate_buffer_seconds': value => $rate_buffer_seconds;
|
||||
'filter:ratelimit/account_ratelimit': value => $account_ratelimit;
|
||||
}
|
||||
|
||||
$container_ratelimit.each | $size, $limit | {
|
||||
swift_proxy_config {
|
||||
"filter:ratelimit/container_ratelimit_${size}": value => $limit;
|
||||
}
|
||||
}
|
||||
|
||||
$container_listing_ratelimit.each | $size, $limit | {
|
||||
swift_proxy_config {
|
||||
"filter:ratelimit/container_listing_ratelimit_${size}": value => $limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The ``swift::proxy::ratelimit`` class now supports the following two new
|
||||
parameters. These parameters accept hash of container size and limit.
|
||||
|
||||
- ``container_ratelimit``
|
||||
- ``container_listing_ratelimit``
|
@@ -28,6 +28,38 @@ describe 'swift::proxy::ratelimit' do
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/rate_buffer_seconds').with_value('5') }
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/account_ratelimit').with_value('0') }
|
||||
end
|
||||
|
||||
describe "with container ratelimit" do
|
||||
let :params do
|
||||
{
|
||||
:container_ratelimit => {
|
||||
0 => 100,
|
||||
10 => 50,
|
||||
50 => 20
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_ratelimit_0').with_value(100) }
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_ratelimit_10').with_value(50) }
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_ratelimit_50').with_value(20) }
|
||||
end
|
||||
|
||||
describe "with container listing ratelimit" do
|
||||
let :params do
|
||||
{
|
||||
:container_listing_ratelimit => {
|
||||
0 => 100,
|
||||
10 => 50,
|
||||
50 => 20
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_listing_ratelimit_0').with_value(100) }
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_listing_ratelimit_10').with_value(50) }
|
||||
it { is_expected.to contain_swift_proxy_config('filter:ratelimit/container_listing_ratelimit_50').with_value(20) }
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
Reference in New Issue
Block a user