diff --git a/README.md b/README.md index 416d828b..b34a8c9c 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,28 @@ This is the ip that the proxy service will bind to when it starts. ####`port` The port for which the proxy service will bind to when it starts. +### Class swift::proxy::dlo + +Configures [DLO middleware](http://docs.openstack.org/developer/swift/middleware.html#module-swift.common.middleware.dlo) for swift proxy. + +```puppet +class { '::swift::proxy::dlo': + rate_limit_after_segment => '10', + rate_limit_segments_per_sec => '1', + max_get_time => '86400' +} +``` + +####`rate_limit_after_segment` +Start rate-limiting DLO segment serving after the Nth segment of a segmented object. + +####`rate_limit_segments_per_sec` +Once segment rate-limiting kicks in for an object, limit segments served to N per second. +0 means no rate-limiting. + +####`max_get_time` +Time limit on GET requests (seconds). + ### Class: swift::storage Class that sets up all of the configuration and dependencies for swift storage server instances. diff --git a/manifests/proxy/dlo.pp b/manifests/proxy/dlo.pp new file mode 100644 index 00000000..ca14547a --- /dev/null +++ b/manifests/proxy/dlo.pp @@ -0,0 +1,43 @@ +# +# Configure swift dlo. +# +# == Examples +# +# include ::swift::proxy::dlo +# +# == Parameters +# +# [*rate_limit_after_segment*] +# Start rate-limiting DLO segment serving after the Nth segment of a segmented object. +# Default to 10. +# +# [*rate_limit_segments_per_sec*] +# Once segment rate-limiting kicks in for an object, limit segments served to N per second. +# 0 means no rate-limiting. +# Default to 1. +# +# [*max_get_time*] +# Time limit on GET requests (seconds). +# Default to 86400. +# +# == Authors +# +# Aleksandr Didenko adidenko@mirantis.com +# +# == Copyright +# +# Copyright 2015 Mirantis Inc, unless otherwise noted. +# +class swift::proxy::dlo ( + $rate_limit_after_segment = '10', + $rate_limit_segments_per_sec = '1', + $max_get_time = '86400' +) { + + concat::fragment { 'swift_dlo': + target => '/etc/swift/proxy-server.conf', + content => template('swift/proxy/dlo.conf.erb'), + order => '36', + } + +} diff --git a/spec/acceptance/basic_swift_spec.rb b/spec/acceptance/basic_swift_spec.rb index 0d2f07eb..8a581a5c 100644 --- a/spec/acceptance/basic_swift_spec.rb +++ b/spec/acceptance/basic_swift_spec.rb @@ -105,14 +105,17 @@ describe 'basic swift' do } class { '::swift::proxy': proxy_local_net_ip => '127.0.0.1', - pipeline => ['healthcheck', 'cache', 'tempauth', 'proxy-server'], + pipeline => ['healthcheck', 'cache', 'tempauth', 'dlo', 'proxy-server'], account_autocreate => true, require => Class['swift::ringbuilder'], } class { '::swift::proxy::authtoken': admin_password => 'a_big_secret', } - class { ['::swift::proxy::healthcheck', '::swift::proxy::cache', '::swift::proxy::tempauth']: } + class { + [ '::swift::proxy::healthcheck', '::swift::proxy::cache', + '::swift::proxy::tempauth', '::swift::proxy::dlo' ]: + } EOS diff --git a/spec/classes/swift_proxy_dlo_spec.rb b/spec/classes/swift_proxy_dlo_spec.rb new file mode 100644 index 00000000..930388b8 --- /dev/null +++ b/spec/classes/swift_proxy_dlo_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe 'swift::proxy::dlo' do + + let :facts do + {} + end + + let :fragment_file do + "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/36_swift_dlo" + end + + describe "when using default parameters" do + it 'should build the fragment with correct parameters' do + verify_contents(catalogue, fragment_file, + [ + '[filter:dlo]', + 'use = egg:swift#dlo', + 'rate_limit_after_segment = 10', + 'rate_limit_segments_per_sec = 1', + 'max_get_time = 86400', + ] + ) + end + end + + describe "when overriding default parameters" do + let :params do + { + :rate_limit_after_segment => '30', + :rate_limit_segments_per_sec => '5', + :max_get_time => '6400', + } + end + it 'should build the fragment with correct parameters' do + verify_contents(catalogue, fragment_file, + [ + '[filter:dlo]', + 'use = egg:swift#dlo', + 'rate_limit_after_segment = 30', + 'rate_limit_segments_per_sec = 5', + 'max_get_time = 6400', + ] + ) + end + end + +end diff --git a/templates/proxy/dlo.conf.erb b/templates/proxy/dlo.conf.erb new file mode 100644 index 00000000..5c70fc14 --- /dev/null +++ b/templates/proxy/dlo.conf.erb @@ -0,0 +1,6 @@ + +[filter:dlo] +use = egg:swift#dlo +rate_limit_after_segment = <%= @rate_limit_after_segment %> +rate_limit_segments_per_sec = <%= @rate_limit_segments_per_sec %> +max_get_time = <%= @max_get_time %>