Add support for backend ratelimit middleware options
This introduces a new defined resource type to manage the backend ratelimit middleware options. The middleware was added recently so that users can ratelimit internal requests. Details can be found in the dependent change. Depends-on: https://review.opendev.org/836046 Change-Id: Ie7c33d0a7e75238be9638551779413d93206cc41
This commit is contained in:
parent
c17989e647
commit
c940ab0ab5
49
manifests/storage/filter/backend_ratelimit.pp
Normal file
49
manifests/storage/filter/backend_ratelimit.pp
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Configure swift backend limit
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*requests_per_device_per_second*]
|
||||
# (optional) Set the maximum rate of requests per second per device per
|
||||
# worker.
|
||||
# Defaults to $::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.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# == Dependencies
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# == Authors
|
||||
#
|
||||
# Takashi Kajinami tkajinam@redhat.com
|
||||
#
|
||||
# == Copyright
|
||||
#
|
||||
# Copyright 2022 Red Hat, unless otherwise noted.
|
||||
#
|
||||
define swift::storage::filter::backend_ratelimit(
|
||||
$requests_per_device_per_second = $::os_service_default,
|
||||
$requests_per_device_rate_buffer = $::os_service_default,
|
||||
) {
|
||||
|
||||
include swift::deps
|
||||
|
||||
$config_type = "swift_${name}_config"
|
||||
|
||||
create_resources($config_type, {
|
||||
'filter:backend_ratelimit/use' => {
|
||||
'value' => 'egg:swift#backend_ratelimit'
|
||||
},
|
||||
'filter:backend_ratelimit/requests_per_device_per_second' => {
|
||||
'value' => $requests_per_device_per_second
|
||||
},
|
||||
'filter:backend_ratelimit/requests_per_device_rate_buffer' => {
|
||||
'value' => $requests_per_device_rate_buffer
|
||||
}
|
||||
})
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``swift::storage::filter::backend_ratelimit`` defined resource type
|
||||
has been added. This defined type configures the backend ratelimit
|
||||
middleware.
|
48
spec/defines/swift_storage_filter_backend_ratelimit_spec.rb
Normal file
48
spec/defines/swift_storage_filter_backend_ratelimit_spec.rb
Normal file
@ -0,0 +1,48 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::filter::backend_ratelimit' do
|
||||
let :title do
|
||||
'account'
|
||||
end
|
||||
|
||||
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>')
|
||||
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
|
||||
}
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_configures 'swift::storage::filter::backend_ratelimit'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user