diff --git a/manifests/internal_client.pp b/manifests/internal_client.pp index be64319c..fdfb63ba 100644 --- a/manifests/internal_client.pp +++ b/manifests/internal_client.pp @@ -24,6 +24,15 @@ # (optional) Method to chose storage nodes during GET and HEAD requests. # Defaults to undef. # +# [*timing_expiry*] +# (optional) If the "timing" sorting_method is used, the timings will only +# be valid for the number of seconds configured by timing_expiry. +# Defaults to $facts['os_service_default']. +# +# [*request_node_count*] +# (optional) Number of nodes to contact for a normal request. +# Defaults to $facts['os_service_default']. +# # [*read_affinity*] # (optional) Configures the read affinity of internal client. # Defaults to undef. @@ -37,6 +46,11 @@ # Optional but requires write_affinity to be set. # Defaults to $facts['os_service_default']. # +# [*write_affinity_handoff_delete_count*] +# (optional) Configures write_affinity_handoff_delete_count for proxy-server. +# Optional but requires write_affinity to be set. +# Defaults to $facts['os_service_default']. +# # [*client_timeout*] # (optional) Configures client_timeout for internal client. # Defaults to $facts['os_service_default']. @@ -60,9 +74,12 @@ class swift::internal_client ( $object_chunk_size = $facts['os_service_default'], $client_chunk_size = $facts['os_service_default'], Optional[Swift::SortingMethod] $sorting_method = undef, + $timing_expiry = $facts['os_service_default'], + $request_node_count = $facts['os_service_default'], $read_affinity = undef, $write_affinity = undef, $write_affinity_node_count = $facts['os_service_default'], + $write_affinity_handoff_delete_count = $facts['os_service_default'], $client_timeout = $facts['os_service_default'], $node_timeout = $facts['os_service_default'], $recoverable_node_timeout = $facts['os_service_default'], @@ -95,6 +112,8 @@ class swift::internal_client ( 'pipeline:main/pipeline': value => join($pipeline, ' '); 'app:proxy-server/use': value => 'egg:swift#proxy'; 'app:proxy-server/account_autocreate': value => true; + 'app:proxy-server/timing_expiry': value => $timing_expiry; + 'app:proxy-server/request_node_count': value => $request_node_count; 'app:proxy-server/object_chunk_size': value => $object_chunk_size; 'app:proxy-server/client_chunk_size': value => $client_chunk_size; 'app:proxy-server/client_timeout': value => $client_timeout; @@ -104,16 +123,21 @@ class swift::internal_client ( if $write_affinity { swift_internal_client_config { - 'app:proxy-server/write_affinity': value => $write_affinity; - 'app:proxy-server/write_affinity_node_count': value => $write_affinity_node_count; + 'app:proxy-server/write_affinity': value => $write_affinity; + 'app:proxy-server/write_affinity_node_count': value => $write_affinity_node_count; + 'app:proxy-server/write_affinity_handoff_delete_count': value => $write_affinity_handoff_delete_count; } } else { if !is_service_default($write_affinity_node_count) { fail('Usage of write_affinity_node_count requires write_affinity to be set') } + if !is_service_default($write_affinity_handoff_delete_count) { + fail('Usage of write_affinity_handoff_delete_count requires write_affinity to be set') + } swift_internal_client_config { - 'app:proxy-server/write_affinity': value => $facts['os_service_default']; - 'app:proxy-server/write_affinity_node_count': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity_node_count': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity_handoff_delete_count': value => $facts['os_service_default']; } } @@ -131,5 +155,4 @@ class swift::internal_client ( 'app:proxy-server/read_affinity': value => $facts['os_service_default']; } } - } diff --git a/manifests/proxy.pp b/manifests/proxy.pp index 5a95d8fe..f2383eb4 100644 --- a/manifests/proxy.pp +++ b/manifests/proxy.pp @@ -82,6 +82,15 @@ # (optional) Method to chose storage nodes during GET and HEAD requests. # Defaults to undef. # +# [*timing_expiry*] +# (optional) If the "timing" sorting_method is used, the timings will only +# be valid for the number of seconds configured by timing_expiry. +# Defaults to $facts['os_service_default']. +# +# [*request_node_count*] +# (optional) Number of nodes to contact for a normal request. +# Defaults to $facts['os_service_default']. +# # [*read_affinity*] # (optional) Configures the read affinity of proxy-server. # Defaults to undef. @@ -95,6 +104,11 @@ # Optional but requires write_affinity to be set. # Defaults to $facts['os_service_default']. # +# [*write_affinity_handoff_delete_count*] +# (optional) Configures write_affinity_handoff_delete_count for proxy-server. +# Optional but requires write_affinity to be set. +# Defaults to $facts['os_service_default']. +# # [*client_timeout*] # (optional) Configures client_timeout for swift proxy-server. # Defaults to $facts['os_service_default']. @@ -193,9 +207,12 @@ class swift::proxy( $max_containers_per_account = $facts['os_service_default'], $max_containers_whitelist = $facts['os_service_default'], Optional[Swift::SortingMethod] $sorting_method = undef, + $timing_expiry = $facts['os_service_default'], + $request_node_count = $facts['os_service_default'], $read_affinity = undef, $write_affinity = undef, $write_affinity_node_count = $facts['os_service_default'], + $write_affinity_handoff_delete_count = $facts['os_service_default'], $client_timeout = $facts['os_service_default'], $keepalive_timeout = $facts['os_service_default'], $node_timeout = $facts['os_service_default'], @@ -275,6 +292,8 @@ class swift::proxy( 'app:proxy-server/account_autocreate': value => $account_autocreate; 'app:proxy-server/max_containers_per_account': value => $max_containers_per_account; 'app:proxy-server/max_containers_whitelist': value => $max_containers_whitelist; + 'app:proxy-server/timing_expiry': value => $timing_expiry; + 'app:proxy-server/request_node_count': value => $request_node_count; 'app:proxy-server/node_timeout': value => $node_timeout; 'app:proxy-server/recoverable_node_timeout': value => $recoverable_node_timeout; 'app:proxy-server/allow_open_expired': value => $allow_open_expired; @@ -288,16 +307,21 @@ class swift::proxy( if $write_affinity { swift_proxy_config { - 'app:proxy-server/write_affinity': value => $write_affinity; - 'app:proxy-server/write_affinity_node_count': value => $write_affinity_node_count; + 'app:proxy-server/write_affinity': value => $write_affinity; + 'app:proxy-server/write_affinity_node_count': value => $write_affinity_node_count; + 'app:proxy-server/write_affinity_handoff_delete_count': value => $write_affinity_handoff_delete_count; } } else { if !is_service_default($write_affinity_node_count) { fail('Usage of write_affinity_node_count requires write_affinity to be set') } + if !is_service_default($write_affinity_handoff_delete_count) { + fail('Usage of write_affinity_handoff_delete_count requires write_affinity to be set') + } swift_proxy_config { - 'app:proxy-server/write_affinity': value => $facts['os_service_default']; - 'app:proxy-server/write_affinity_node_count': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity_node_count': value => $facts['os_service_default']; + 'app:proxy-server/write_affinity_handoff_delete_count': value => $facts['os_service_default']; } } diff --git a/releasenotes/notes/request-opts-d5dd2a93ecfee6b7.yaml b/releasenotes/notes/request-opts-d5dd2a93ecfee6b7.yaml new file mode 100644 index 00000000..85787494 --- /dev/null +++ b/releasenotes/notes/request-opts-d5dd2a93ecfee6b7.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + The following new parameters have been added to the ``swift::proxy`` class + and the ``swift::internal_client`` class. + + - ``timing_expiry`` + - ``request_node_count`` + - ``write_affinity_handoff_delete_count`` diff --git a/spec/classes/swift_internal_client_spec.rb b/spec/classes/swift_internal_client_spec.rb index 3d9e64f0..226eedd5 100644 --- a/spec/classes/swift_internal_client_spec.rb +++ b/spec/classes/swift_internal_client_spec.rb @@ -27,9 +27,12 @@ describe 'swift::internal_client' do should contain_swift_internal_client_config('app:proxy-server/object_chunk_size').with_value('') should contain_swift_internal_client_config('app:proxy-server/client_chunk_size').with_value('') should contain_swift_internal_client_config('app:proxy-server/sorting_method').with_value('') + should contain_swift_internal_client_config('app:proxy-server/timing_expiry').with_value('') + should contain_swift_internal_client_config('app:proxy-server/request_node_count').with_value('') should contain_swift_internal_client_config('app:proxy-server/read_affinity').with_value('') should contain_swift_internal_client_config('app:proxy-server/write_affinity').with_value('') should contain_swift_internal_client_config('app:proxy-server/write_affinity_node_count').with_value('') + should contain_swift_internal_client_config('app:proxy-server/write_affinity_handoff_delete_count').with_value('') should contain_swift_internal_client_config('app:proxy-server/client_timeout').with_value('') should contain_swift_internal_client_config('app:proxy-server/node_timeout').with_value('') should contain_swift_internal_client_config('app:proxy-server/recoverable_node_timeout').with_value('') @@ -39,15 +42,18 @@ describe 'swift::internal_client' do context 'with parameters' do let :params do { - :pipeline => ['catch_errors', 'proxy-logging', 'proxy-server'], - :object_chunk_size => 65536, - :client_chunk_size => 65535, - :read_affinity => 'r1z1=100, r1=200', - :write_affinity => 'r1', - :write_affinity_node_count => '2 * replicas', - :client_timeout => '120', - :node_timeout => '20', - :recoverable_node_timeout => '15', + :pipeline => ['catch_errors', 'proxy-logging', 'proxy-server'], + :object_chunk_size => 65536, + :client_chunk_size => 65535, + :timing_expiry => 300, + :request_node_count => '2 * replicas', + :read_affinity => 'r1z1=100, r1=200', + :write_affinity => 'r1', + :write_affinity_node_count => '2 * replicas', + :write_affinity_handoff_delete_count => 'auto', + :client_timeout => '120', + :node_timeout => '20', + :recoverable_node_timeout => '15', } end @@ -56,9 +62,12 @@ describe 'swift::internal_client' do should contain_swift_internal_client_config('app:proxy-server/object_chunk_size').with_value(65536) should contain_swift_internal_client_config('app:proxy-server/client_chunk_size').with_value(65535) should contain_swift_internal_client_config('app:proxy-server/sorting_method').with_value('affinity') + should contain_swift_internal_client_config('app:proxy-server/timing_expiry').with_value(300) + should contain_swift_internal_client_config('app:proxy-server/request_node_count').with_value('2 * replicas') should contain_swift_internal_client_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200') should contain_swift_internal_client_config('app:proxy-server/write_affinity').with_value('r1') should contain_swift_internal_client_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas') + should contain_swift_internal_client_config('app:proxy-server/write_affinity_handoff_delete_count').with_value('auto') should contain_swift_internal_client_config('app:proxy-server/client_timeout').with_value('120') should contain_swift_internal_client_config('app:proxy-server/node_timeout').with_value('20') should contain_swift_internal_client_config('app:proxy-server/recoverable_node_timeout').with_value('15') diff --git a/spec/classes/swift_proxy_spec.rb b/spec/classes/swift_proxy_spec.rb index f23719cb..5e72cea1 100644 --- a/spec/classes/swift_proxy_spec.rb +++ b/spec/classes/swift_proxy_spec.rb @@ -83,8 +83,11 @@ describe 'swift::proxy' do it { should contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('true') } it { should contain_swift_proxy_config('app:proxy-server/max_containers_per_account').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/max_containers_whitelist').with_value('') } + it { should contain_swift_proxy_config('app:proxy-server/timing_expiry').with_value('') } + it { should contain_swift_proxy_config('app:proxy-server/request_node_count').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('') } + it { should contain_swift_proxy_config('app:proxy-server/write_affinity_handoff_delete_count').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/recoverable_node_timeout').with_value('') } it { should contain_swift_proxy_config('app:proxy-server/allow_open_expired').with_value('') } @@ -131,30 +134,33 @@ describe 'swift::proxy' do let :params do { - :proxy_local_net_ip => '10.0.0.2', - :port => '80', - :workers => 3, - :pipeline => ['swauth', 'proxy-server'], - :allow_account_management => false, - :account_autocreate => false, - :log_level => 'DEBUG', - :log_headers => false, - :log_name => 'swift-proxy-server', - :object_chunk_size => '8192', - :client_chunk_size => '8192', - :max_containers_per_account => 10, - :max_containers_whitelist => 'project1,project2', - :read_affinity => 'r1z1=100, r1=200', - :write_affinity => 'r1', - :write_affinity_node_count => '2 * replicas', - :client_timeout => '120', - :keepalive_timeout => '121', - :node_timeout => '20', - :recoverable_node_timeout => '15', - :allow_open_expired => false, - :cors_allow_origin => ['http://foo.bar:1234', 'https://foo.bar'], - :strict_cors_mode => true, - :cors_expose_headers => ['header-a', 'header-b'], + :proxy_local_net_ip => '10.0.0.2', + :port => '80', + :workers => 3, + :pipeline => ['swauth', 'proxy-server'], + :allow_account_management => false, + :account_autocreate => false, + :log_level => 'DEBUG', + :log_headers => false, + :log_name => 'swift-proxy-server', + :object_chunk_size => '8192', + :client_chunk_size => '8192', + :max_containers_per_account => 10, + :max_containers_whitelist => 'project1,project2', + :timing_expiry => 300, + :request_node_count => '2 * replicas', + :read_affinity => 'r1z1=100, r1=200', + :write_affinity => 'r1', + :write_affinity_node_count => '2 * replicas', + :write_affinity_handoff_delete_count => 'auto', + :client_timeout => '120', + :keepalive_timeout => '121', + :node_timeout => '20', + :recoverable_node_timeout => '15', + :allow_open_expired => false, + :cors_allow_origin => ['http://foo.bar:1234', 'https://foo.bar'], + :strict_cors_mode => true, + :cors_expose_headers => ['header-a', 'header-b'], } end @@ -182,10 +188,13 @@ describe 'swift::proxy' do it { should contain_swift_proxy_config('app:proxy-server/account_autocreate').with_value('false') } it { should contain_swift_proxy_config('app:proxy-server/max_containers_per_account').with_value(10) } it { should contain_swift_proxy_config('app:proxy-server/max_containers_whitelist').with_value('project1,project2') } + it { should contain_swift_proxy_config('app:proxy-server/timing_expiry').with_value(300) } + it { should contain_swift_proxy_config('app:proxy-server/request_node_count').with_value('2 * replicas') } it { should contain_swift_proxy_config('app:proxy-server/sorting_method').with_value('affinity') } it { should contain_swift_proxy_config('app:proxy-server/read_affinity').with_value('r1z1=100, r1=200') } it { should contain_swift_proxy_config('app:proxy-server/write_affinity').with_value('r1') } it { should contain_swift_proxy_config('app:proxy-server/write_affinity_node_count').with_value('2 * replicas') } + it { should contain_swift_proxy_config('app:proxy-server/write_affinity_handoff_delete_count').with_value('auto') } it { should contain_swift_proxy_config('app:proxy-server/node_timeout').with_value('20') } it { should contain_swift_proxy_config('app:proxy-server/recoverable_node_timeout').with_value('15') } it { should contain_swift_proxy_config('app:proxy-server/allow_open_expired').with_value(false) } @@ -239,15 +248,30 @@ describe 'swift::proxy' do end end - let :params do - { - :proxy_local_net_ip => '127.0.0.1', - :write_affinity_node_count => '2 * replicas' - } + context 'write_affinity_node_count set without write_affinity' do + let :params do + { + :proxy_local_net_ip => '127.0.0.1', + :write_affinity_node_count => '2 * replicas' + } + end + + it 'should fail if write_affinity_node_count is used without write_affinity' do + should raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/) + end end - it 'should fail if write_affinity_node_count is used without write_affinity' do - should raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/) + context 'write_affinity_handoff_delete_count set without write_affinity' do + let :params do + { + :proxy_local_net_ip => '127.0.0.1', + :write_affinity_handoff_delete_count => 'auto' + } + end + + it 'should fail if write_affinity_handoff_delete_count is used without write_affinity' do + should raise_error(Puppet::Error, /write_affinity_handoff_delete_count requires write_affinity/) + end end end end