Add read_affinity, write_affinity support to proxy

This optionally provides the ability to configure read and write affinity
in proxy-server.conf.
Documentation: http://docs.openstack.org/developer/swift/admin_guide.html

Change-Id: Iea5aa6f73ddbdef119c5e70b29820c43640f0dac
This commit is contained in:
David Moreau Simard 2014-04-08 12:54:57 -04:00
parent 003838325a
commit ed3ba7f889
3 changed files with 48 additions and 8 deletions

View File

@ -25,6 +25,13 @@
# delete accounts. Optional. Defaults to true. # delete accounts. Optional. Defaults to true.
# [*account_autocreate*] Rather accounts should automatically be created. # [*account_autocreate*] Rather accounts should automatically be created.
# Has to be set to true for tempauth. Optional. Defaults to true. # Has to be set to true for tempauth. Optional. Defaults to true.
# [*read_affinity*]
# Configures the read affinity of proxy-server. Optional. Defaults to undef.
# [*write_affinity*]
# Configures the write affinity of proxy-server. Optional. Defaults to undef.
# [*write_affinity_node_count*]
# Configures write_affinity_node_count for proxy-server.
# Optional but requires write_affinity to be set. Defaults to undef.
# [*package_ensure*] Ensure state of the swift proxy package. # [*package_ensure*] Ensure state of the swift proxy package.
# Optional. Defaults to present. # Optional. Defaults to present.
# #
@ -52,6 +59,9 @@ class swift::proxy(
$log_level = 'INFO', $log_level = 'INFO',
$log_facility = 'LOG_LOCAL1', $log_facility = 'LOG_LOCAL1',
$log_handoffs = true, $log_handoffs = true,
$read_affinity = undef,
$write_affinity = undef,
$write_affinity_node_count = undef,
$package_ensure = 'present' $package_ensure = 'present'
) { ) {
@ -62,6 +72,10 @@ class swift::proxy(
validate_bool($allow_account_management) validate_bool($allow_account_management)
validate_array($pipeline) validate_array($pipeline)
if($write_affinity_node_count and ! $write_affinity) {
fail('Usage of write_affinity_node_count requires write_affinity to be set')
}
if(member($pipeline, 'tempauth')) { if(member($pipeline, 'tempauth')) {
$auth_type = 'tempauth' $auth_type = 'tempauth'
} elsif(member($pipeline, 'swauth')) { } elsif(member($pipeline, 'swauth')) {

View File

@ -92,13 +92,16 @@ describe 'swift::proxy' do
describe 'when more parameters are set' do describe 'when more parameters are set' do
let :params do let :params do
{ {
:proxy_local_net_ip => '10.0.0.2', :proxy_local_net_ip => '10.0.0.2',
:port => '80', :port => '80',
:workers => 3, :workers => 3,
:pipeline => ['swauth', 'proxy-server'], :pipeline => ['swauth', 'proxy-server'],
:allow_account_management => false, :allow_account_management => false,
:account_autocreate => false, :account_autocreate => false,
:log_level => 'DEBUG' :log_level => 'DEBUG',
:read_affinity => 'r1z1=100, r1=200',
:write_affinity => 'r1',
:write_affinity_node_count => '2 * replicas',
} }
end end
it 'should build the header file with provided values' do it 'should build the header file with provided values' do
@ -114,7 +117,10 @@ describe 'swift::proxy' do
'[app:proxy-server]', '[app:proxy-server]',
'use = egg:swift#proxy', 'use = egg:swift#proxy',
'allow_account_management = false', 'allow_account_management = false',
'account_autocreate = false' 'account_autocreate = false',
'read_affinity = r1z1=100, r1=200',
'write_affinity = r1',
'write_affinity_node_count = 2 * replicas'
] ]
) )
end end
@ -130,6 +136,17 @@ describe 'swift::proxy' do
expect { subject }.to raise_error(Puppet::Error, /is not a boolean/) expect { subject }.to raise_error(Puppet::Error, /is not a boolean/)
end end
end end
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
expect { subject }.to raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/)
end
end end
end end

View File

@ -32,3 +32,12 @@ set log_address = <%= @log_address %>
log_handoffs = <%= @log_handoffs %> log_handoffs = <%= @log_handoffs %>
allow_account_management = <%= @allow_account_management %> allow_account_management = <%= @allow_account_management %>
account_autocreate = <%= @account_autocreate %> account_autocreate = <%= @account_autocreate %>
<% if @read_affinity -%>
read_affinity = <%= @read_affinity -%>
<% end %>
<% if @write_affinity -%>
write_affinity = <%= @write_affinity -%>
<% end %>
<% if @write_affinity_node_count -%>
write_affinity_node_count = <%= @write_affinity_node_count -%>
<% end %>