Merge "Support per-method backend ratelimit options"

This commit is contained in:
Zuul 2024-07-29 08:52:26 +00:00 committed by Gerrit Code Review
commit d9eda0394f
3 changed files with 139 additions and 17 deletions

View File

@ -8,6 +8,41 @@
# worker.
# Defaults to $facts['os_service_default']
#
# [*delete_requests_per_device_per_second*]
# (optional) Set the maximum rate of DELETE requests per second per device
# per worker.
# Defaults to $facts['os_service_default']
#
# [*get_requests_per_device_per_second*]
# (optional) Set the maximum rate of GET requests per second per device per
# worker.
# Defaults to $facts['os_service_default']
#
# [*head_requests_per_device_per_second*]
# (optional) Set the maximum rate of HEAD requests per second per device per
# worker.
# Defaults to $facts['os_service_default']
#
# [*post_requests_per_device_per_second*]
# (optional) Set the maximum rate of POST requests per second per device per
# worker.
# Defaults to $facts['os_service_default']
#
# [*put_requests_per_device_per_second*]
# (optional) Set the maximum rate of PUT requests per second per device per
# worker.
# Defaults to $facts['os_service_default']
#
# [*replicate_requests_per_device_per_second*]
# (optional) Set the maximum rate of REPLICATE requests per second per device
# per worker.
# Defaults to $facts['os_service_default']
#
# [*update_requests_per_device_per_second*]
# (optional) Set the maximum rate of UPDATE requests per second per device
# per worker.
# Defaults to $facts['os_service_default']
#
# [*requests_per_device_rate_buffer*]
# (optional) Set the number of seconds of unused rate-limiting allowance that
# can accumulate and be used to allow a subsequent burst of requests.
@ -26,8 +61,15 @@
# Copyright 2022 Red Hat, unless otherwise noted.
#
define swift::storage::filter::backend_ratelimit(
$requests_per_device_per_second = $facts['os_service_default'],
$requests_per_device_rate_buffer = $facts['os_service_default'],
$requests_per_device_per_second = $facts['os_service_default'],
$delete_requests_per_device_per_second = $facts['os_service_default'],
$get_requests_per_device_per_second = $facts['os_service_default'],
$head_requests_per_device_per_second = $facts['os_service_default'],
$post_requests_per_device_per_second = $facts['os_service_default'],
$put_requests_per_device_per_second = $facts['os_service_default'],
$replicate_requests_per_device_per_second = $facts['os_service_default'],
$update_requests_per_device_per_second = $facts['os_service_default'],
$requests_per_device_rate_buffer = $facts['os_service_default'],
) {
include swift::deps
@ -35,13 +77,34 @@ define swift::storage::filter::backend_ratelimit(
$config_type = "swift_${name}_config"
create_resources($config_type, {
'filter:backend_ratelimit/use' => {
'filter:backend_ratelimit/use' => {
'value' => 'egg:swift#backend_ratelimit'
},
'filter:backend_ratelimit/requests_per_device_per_second' => {
'filter:backend_ratelimit/requests_per_device_per_second' => {
'value' => $requests_per_device_per_second
},
'filter:backend_ratelimit/requests_per_device_rate_buffer' => {
'filter:backend_ratelimit/delete_requests_per_device_per_second' => {
'value' => $delete_requests_per_device_per_second
},
'filter:backend_ratelimit/get_requests_per_device_per_second' => {
'value' => $get_requests_per_device_per_second
},
'filter:backend_ratelimit/head_requests_per_device_per_second' => {
'value' => $head_requests_per_device_per_second
},
'filter:backend_ratelimit/post_requests_per_device_per_second' => {
'value' => $post_requests_per_device_per_second
},
'filter:backend_ratelimit/put_requests_per_device_per_second' => {
'value' => $put_requests_per_device_per_second
},
'filter:backend_ratelimit/replicate_requests_per_device_per_second' => {
'value' => $replicate_requests_per_device_per_second
},
'filter:backend_ratelimit/update_requests_per_device_per_second' => {
'value' => $update_requests_per_device_per_second
},
'filter:backend_ratelimit/requests_per_device_rate_buffer' => {
'value' => $requests_per_device_rate_buffer
}
})

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``swift::storage::filter::backend_ratelimite`` defined resource type
supports options for per-method rate limits.

View File

@ -8,28 +8,82 @@ describe 'swift::storage::filter::backend_ratelimit' do
shared_examples 'swift::storage::filter::backend_ratelimit' do
describe 'when passing default parameters' do
it 'should configure the backend_ratelimit middleware' do
is_expected.to contain_swift_account_config('filter:backend_ratelimit/use').\
with_value('egg:swift#backend_ratelimit')
is_expected.to contain_swift_account_config('filter:backend_ratelimit/requests_per_device_per_second').\
with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config('filter:backend_ratelimit/requests_per_device_rate_buffer').\
with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/use'
).with_value('egg:swift#backend_ratelimit')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/delete_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/get_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/head_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/post_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/put_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/replicate_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/update_requests_per_device_per_second'
).with_value('<SERVICE DEFAULT>')
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/requests_per_device_rate_buffer'
).with_value('<SERVICE DEFAULT>')
end
end
describe 'when overriding default parameters' do
let :params do
{
:requests_per_device_per_second => 0.0,
:requests_per_device_rate_buffer => 1.0
:requests_per_device_per_second => 10.0,
:delete_requests_per_device_per_second => 11.0,
:get_requests_per_device_per_second => 12.0,
:head_requests_per_device_per_second => 13.0,
:post_requests_per_device_per_second => 14.0,
:put_requests_per_device_per_second => 15.0,
:replicate_requests_per_device_per_second => 16.0,
:update_requests_per_device_per_second => 17.0,
:requests_per_device_rate_buffer => 1.0
}
end
it 'should configure the backend_ratelimit middleware' do
is_expected.to contain_swift_account_config('filter:backend_ratelimit/requests_per_device_per_second').\
with_value(0.0)
is_expected.to contain_swift_account_config('filter:backend_ratelimit/requests_per_device_rate_buffer').\
with_value(1.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/requests_per_device_per_second'
).with_value(10.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/delete_requests_per_device_per_second'
).with_value(11.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/get_requests_per_device_per_second'
).with_value(12.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/head_requests_per_device_per_second'
).with_value(13.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/post_requests_per_device_per_second'
).with_value(14.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/put_requests_per_device_per_second'
).with_value(15.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/replicate_requests_per_device_per_second'
).with_value(16.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/update_requests_per_device_per_second'
).with_value(17.0)
is_expected.to contain_swift_account_config(
'filter:backend_ratelimit/requests_per_device_rate_buffer'
).with_value(1.0)
end
end
end