Use Common bind endpoint

More cleanup and work to use the Common support.
* use the common defined object storage api bind endpoint
* allow workers for each server
* adjust cidr to reflect common network defaults
* cleanup out of date comments from templates
* beefed up spec tests a bit

Change-Id: I556ebc28834630c96c686d18a0250241068c095a
This commit is contained in:
Mark Vanderwiel 2014-11-20 15:40:56 -06:00
parent c0202fcbc7
commit ff934f0f4f
13 changed files with 73 additions and 91 deletions

View File

@ -7,6 +7,7 @@ This file is used to list changes made in each version of cookbook-openstack-obj
* Upgrading berkshelf from 2.0.18 to 3.1.5
* Bump Chef gem to 11.16
* Add keystone registration support
* Use Common bind endpoint
## 9.0.3
* Bugfix run_command exitstatus

View File

@ -134,10 +134,11 @@ default['openstack']['object-storage']['statistics']['recon_object_cache'] = '/v
# resolve the appropriate addresses to use for internode
# communication
# Deprecated in Juno, use Common attributes instead
# proxy servers
default['openstack']['object-storage']['network']['proxy-bind-ip'] = '0.0.0.0'
default['openstack']['object-storage']['network']['proxy-bind-port'] = '8080'
default['openstack']['object-storage']['network']['proxy-cidr'] = '10.0.0.0/24'
default['openstack']['object-storage']['network']['proxy-bind-ip'] = nil
default['openstack']['object-storage']['network']['proxy-bind-port'] = nil
default['openstack']['object-storage']['network']['proxy-cidr'] = '127.0.0.0/8'
# account servers
default['openstack']['object-storage']['network']['account-bind-ip'] = '0.0.0.0'
@ -150,7 +151,7 @@ default['openstack']['object-storage']['network']['container-bind-port'] =
# object servers
default['openstack']['object-storage']['network']['object-bind-ip'] = '0.0.0.0'
default['openstack']['object-storage']['network']['object-bind-port'] = '6000'
default['openstack']['object-storage']['network']['object-cidr'] = '10.0.0.0/24'
default['openstack']['object-storage']['network']['object-cidr'] = '127.0.0.0/8'
#------------------
# sysctl
@ -183,6 +184,15 @@ default['openstack']['object-storage']['disk_test_filter'] = [
# template overrides
#-------------------
# Use an integer to override the number of pre-forked processes that will
# accept connections. Should default to the number of effective cpu
# cores in the system. It's worth noting that individual workers will
# use many eventlet co-routines to service multiple concurrent requests.
default['openstack']['object-storage']['proxy-server']['workers'] = 'auto'
default['openstack']['object-storage']['account-server']['workers'] = 'auto'
default['openstack']['object-storage']['container-server']['workers'] = 'auto'
default['openstack']['object-storage']['object-server']['workers'] = 'auto'
# proxy-server
# enable or disable formpost

View File

@ -18,6 +18,10 @@
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
class Chef::Recipe # rubocop:disable Documentation
include DriveUtils
end

View File

@ -127,6 +127,13 @@ else
authkey = swift_secrets['swift_authkey']
end
proxy_api_bind = endpoint 'object-storage-api-bind'
proxy_api_bind_port = node['openstack']['object-storage']['network']['proxy-bind-port']
proxy_api_bind_port = proxy_api_bind.port if proxy_api_bind_port.nil?
proxy_api_bind_host = node['openstack']['object-storage']['network']['proxy-bind-ip']
proxy_api_bind_host = proxy_api_bind.host if proxy_api_bind_host.nil?
# create proxy config file
template '/etc/swift/proxy-server.conf' do
source 'proxy-server.conf.erb'
@ -135,8 +142,8 @@ template '/etc/swift/proxy-server.conf' do
mode 0600
variables(
'authmode' => node['openstack']['object-storage']['authmode'],
'bind_host' => node['openstack']['object-storage']['network']['proxy-bind-ip'],
'bind_port' => node['openstack']['object-storage']['network']['proxy-bind-port'],
'bind_host' => proxy_api_bind_host,
'bind_port' => proxy_api_bind_port,
'authkey' => authkey,
'memcache_servers' => memcache_servers
)

View File

@ -46,14 +46,10 @@ describe 'openstack-object-storage::account-server' do
end
describe 'default attribute values' do
it_behaves_like 'a common swift server default attribute values checker', 'account'
it 'uses default attribute value for bind_port' do
expect(chef_run.node['openstack']['object-storage']['network']['account-bind-port']).to eq('6002')
end
it_behaves_like 'a common swift server default attribute values checker', 'account', '0.0.0.0', '6002'
end
it_behaves_like 'a common swift server configurator', 'account'
it_behaves_like 'a common swift server configurator', 'account', '0.0.0.0', '6002'
end
end
end

View File

@ -50,20 +50,24 @@ describe 'openstack-object-storage::container-server' do
describe '/etc/swift/container-server.conf' do
let(:file) { chef_run.template('/etc/swift/container-server.conf') }
describe 'default attribute values' do
it_behaves_like 'a common swift server default attribute values checker', 'container'
it 'for bind_port' do
expect(chef_run.node['openstack']['object-storage']['network']['container-bind-port']).to eq('6001')
it 'creates account-server.conf' do
expect(chef_run).to create_template(file.name).with(
user: 'swift',
group: 'swift',
mode: 0600
)
end
describe 'default attribute values' do
it_behaves_like 'a common swift server default attribute values checker', 'container', '0.0.0.0', '6001'
it 'for allowed_sync_hosts' do
expect(chef_run.node['openstack']['object-storage']['container-server']['allowed_sync_hosts']).to eq([])
end
end
describe 'template contents' do
it_behaves_like 'a common swift server configurator', 'container'
it_behaves_like 'a common swift server configurator', 'container', '0.0.0.0', '6001'
it 'sets allowed_sync_hosts when present' do
node.set['openstack']['object-storage']['container-server']['allowed_sync_hosts'] = %w(host1 host2)

View File

@ -48,14 +48,10 @@ describe 'openstack-object-storage::object-server' do
end
describe 'default attribute values' do
it_behaves_like 'a common swift server default attribute values checker', 'object'
it 'uses default attribute value for bind_port' do
expect(chef_run.node['openstack']['object-storage']['network']['object-bind-port']).to eq('6000')
end
it_behaves_like 'a common swift server default attribute values checker', 'object', '0.0.0.0', '6000'
end
it_behaves_like 'a common swift server configurator', 'object'
it_behaves_like 'a common swift server configurator', 'object', '0.0.0.0', '6000'
end
end
end

View File

@ -42,11 +42,7 @@ describe 'openstack-object-storage::proxy-server' do
end
describe 'default attribute values' do
it_behaves_like 'a common swift server default attribute values checker', 'proxy'
it 'uses default attribute value for bind_port' do
expect(chef_run.node['openstack']['object-storage']['network']['proxy-bind-port']).to eq('8080')
end
it_behaves_like 'a common swift server default attribute values checker', 'proxy', nil, nil
it 'uses default attribute value for authmode' do
expect(chef_run.node['openstack']['object-storage']['authmode']).to eq('swauth')
@ -146,17 +142,11 @@ describe 'openstack-object-storage::proxy-server' do
end
describe 'template contents' do
it_behaves_like 'a common swift server configurator', 'proxy'
it_behaves_like 'a common swift server configurator', 'proxy', '127.0.0.1', '8080'
context 'workers' do
it 'sets the number of workers' do
chef_run.node.automatic['cpu']['total'] = 8
expect(chef_run).to render_file(file.name).with_content(/^workers = 7$/)
end
it 'sets the minimum numnber of workers' do
chef_run.node.automatic['cpu']['total'] = 0
expect(chef_run).to render_file(file.name).with_content(/^workers = 1$/)
expect(chef_run).to render_file(file.name).with_content(/^workers = auto$/)
end
end

View File

@ -96,7 +96,17 @@ shared_examples 'keystone-authmode' do
end
end
shared_examples 'a common swift server configurator' do |server_type|
shared_examples 'a common swift server configurator' do |server_type, bind_ip, bind_port|
{ 'bind_ip' => "#{bind_ip}",
'bind_port' => "#{bind_port}",
'log_statsd_default_sample_rate' => '1',
'log_statsd_metric_prefix' => 'openstack.swift.Fauxhai',
'workers' => 'auto' }.each do |k, v|
it "sets the default for #{k}" do
expect(chef_run).to render_file(file.name).with_content(/^#{Regexp.quote("#{k} = #{v}")}$/)
end
end
%w(ip port).each do |attr|
it "sets the bind_#{attr} attr" do
node.set['openstack']['object-storage']['network']["#{server_type}-bind-#{attr}"] = "#{attr}_value"
@ -127,9 +137,13 @@ shared_examples 'a common swift server configurator' do |server_type|
end
end
shared_examples 'a common swift server default attribute values checker' do |server_type|
shared_examples 'a common swift server default attribute values checker' do |server_type, bind_ip, bind_port|
it 'bind_ip' do
expect(chef_run.node['openstack']['object-storage']['network']["#{server_type}-bind-ip"]).to eq('0.0.0.0')
expect(chef_run.node['openstack']['object-storage']['network']["#{server_type}-bind-ip"]).to eq(bind_ip)
end
it 'bind_port' do
expect(chef_run.node['openstack']['object-storage']['network']["#{server_type}-bind-port"]).to eq(bind_port)
end
it 'log_statsd_default_sample_rate' do
@ -143,4 +157,8 @@ shared_examples 'a common swift server default attribute values checker' do |ser
it 'hostname' do
expect(chef_run.node['hostname']).to eq('Fauxhai')
end
it 'workers' do
expect(chef_run.node['openstack']['object-storage']["#{server_type}-server"]['workers']).to eq('auto')
end
end

View File

@ -14,7 +14,7 @@
#####
bind_ip = <%= @bind_ip %>
bind_port = <%= @bind_port %>
workers = 10
workers = <%= node['openstack']['object-storage']['account-server']['workers'] %>
<% if node['openstack']['object-storage']['statistics']['enabled'] -%>
log_statsd_host = localhost
log_statsd_port = 8125

View File

@ -1,23 +1,7 @@
[DEFAULT]
# bind_ip = 0.0.0.0
# bind_port = 6001
# backlog = 4096
# workers = 1
# user = swift
# swift_dir = /etc/swift
# devices = /srv/node
# mount_check = true
# This is a comma separated list of hosts allowed in the X-Container-Sync-To
# field for containers.
# allowed_sync_hosts = 127.0.0.1
# You can specify default log routing here if you want:
# log_name = swift
# log_facility = LOG_LOCAL0
# log_level = INFO
####
bind_ip = <%= @bind_ip %>
bind_port = <%= @bind_port %>
workers = 10
workers = <%= node['openstack']['object-storage']['container-server']['workers'] %>
<% if node['openstack']['object-storage']['statistics']['enabled'] -%>
log_statsd_host = localhost
log_statsd_port = 8125

View File

@ -1,21 +1,7 @@
[DEFAULT]
# bind_ip = 0.0.0.0
# bind_port = 6000
# backlog = 4096
# workers = 1
# user = swift
# swift_dir = /etc/swift
# devices = /srv/node
# mount_check = true
# expiring_objects_container_divisor = 86400
# You can specify default log routing here if you want:
# log_name = swift
# log_facility = LOG_LOCAL0
# log_level = INFO
#####
bind_ip = <%= @bind_ip %>
bind_port = <%= @bind_port %>
workers = 10
workers = <%= node['openstack']['object-storage']['object-server']['workers'] %>
<% if node['openstack']['object-storage']['statistics']['enabled'] -%>
log_statsd_host = localhost
log_statsd_port = 8125

View File

@ -45,23 +45,9 @@ end
# Auth pipeline: <%= pipeline %>
[DEFAULT]
# bind_ip = 0.0.0.0
# bind_port = 8080
# backlog = 4096
# swift_dir = /etc/swift
# workers = 1
# user = swift
# cert_file = /etc/swift/proxy.crt
# key_file = /etc/swift/proxy.key
# expiring_objects_container_divisor = 86400
# You can specify default log routing here if you want:
# log_name = swift
# log_facility = LOG_LOCAL0
# log_level = INFO
######
bind_ip = <%= @bind_host %>
bind_port = <%= @bind_port %>
workers = <%= [ node['cpu']['total'] - 1, 1 ].max %>
workers = <%= node['openstack']['object-storage']['proxy-server']['workers'] %>
<% if node['openstack']['object-storage']['statistics']['enabled'] -%>
log_statsd_host = localhost
log_statsd_port = 8125