diff --git a/manifests/storage/filter/backend_ratelimit.pp b/manifests/storage/filter/backend_ratelimit.pp index 865ed5b4..0213e576 100644 --- a/manifests/storage/filter/backend_ratelimit.pp +++ b/manifests/storage/filter/backend_ratelimit.pp @@ -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 } }) diff --git a/releasenotes/notes/per-method-backend-ratelimit-d242e8c1bbc3d7cb.yaml b/releasenotes/notes/per-method-backend-ratelimit-d242e8c1bbc3d7cb.yaml new file mode 100644 index 00000000..cbb41de3 --- /dev/null +++ b/releasenotes/notes/per-method-backend-ratelimit-d242e8c1bbc3d7cb.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The ``swift::storage::filter::backend_ratelimite`` defined resource type + supports options for per-method rate limits. diff --git a/spec/defines/swift_storage_filter_backend_ratelimit_spec.rb b/spec/defines/swift_storage_filter_backend_ratelimit_spec.rb index 816d0506..12dc1b90 100644 --- a/spec/defines/swift_storage_filter_backend_ratelimit_spec.rb +++ b/spec/defines/swift_storage_filter_backend_ratelimit_spec.rb @@ -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('') - is_expected.to contain_swift_account_config('filter:backend_ratelimit/requests_per_device_rate_buffer').\ - with_value('') + 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('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/delete_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/get_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/head_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/post_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/put_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/replicate_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/update_requests_per_device_per_second' + ).with_value('') + is_expected.to contain_swift_account_config( + 'filter:backend_ratelimit/requests_per_device_rate_buffer' + ).with_value('') 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