Added rsyslog logging support to object-server
Also change both proxy-server and object-server .conf templates to test if log_udp_server and log_udp_port are nil, instead of an empty string. Testing for an empty string would have retruned true if set to 'undef' - for futer parser compat. Change-Id: Idac805f628dbec70a4adb6a1c021d85a743fdb72
This commit is contained in:
@@ -116,8 +116,8 @@ class swift::proxy(
|
|||||||
$allow_account_management = true,
|
$allow_account_management = true,
|
||||||
$account_autocreate = true,
|
$account_autocreate = true,
|
||||||
$log_headers = 'False',
|
$log_headers = 'False',
|
||||||
$log_udp_host = '',
|
$log_udp_host = undef,
|
||||||
$log_udp_port = '',
|
$log_udp_port = undef,
|
||||||
$log_address = '/dev/log',
|
$log_address = '/dev/log',
|
||||||
$log_level = 'INFO',
|
$log_level = 'INFO',
|
||||||
$log_facility = 'LOG_LOCAL1',
|
$log_facility = 'LOG_LOCAL1',
|
||||||
@@ -163,6 +163,10 @@ class swift::proxy(
|
|||||||
fail('account_autocreate must be set to true when auth_type is tempauth')
|
fail('account_autocreate must be set to true when auth_type is tempauth')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($log_udp_port and !$log_udp_host) {
|
||||||
|
fail ('log_udp_port requires log_udp_host to be set')
|
||||||
|
}
|
||||||
|
|
||||||
package { 'swift-proxy':
|
package { 'swift-proxy':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $::swift::params::proxy_package_name,
|
name => $::swift::params::proxy_package_name,
|
||||||
|
@@ -46,6 +46,18 @@
|
|||||||
# (optional) Syslog log facility
|
# (optional) Syslog log facility
|
||||||
# Defaults to 'LOG_LOCAL2'
|
# Defaults to 'LOG_LOCAL2'
|
||||||
#
|
#
|
||||||
|
# [*log_level*]
|
||||||
|
# (optional) Log level.
|
||||||
|
# Defaults to 'INFO'.
|
||||||
|
#
|
||||||
|
# [*log_udp_host*]
|
||||||
|
# (optional) If not set, the UDP receiver for syslog is disabled.
|
||||||
|
# Defaults to undef.
|
||||||
|
#
|
||||||
|
# [*log_udp_port*]
|
||||||
|
# (optional) Port value for UDP receiver, if enabled.
|
||||||
|
# Defaults to undef.
|
||||||
|
#
|
||||||
class swift::storage::all(
|
class swift::storage::all(
|
||||||
$storage_local_net_ip,
|
$storage_local_net_ip,
|
||||||
$devices = '/srv/node',
|
$devices = '/srv/node',
|
||||||
@@ -57,7 +69,10 @@ class swift::storage::all(
|
|||||||
$allow_versions = false,
|
$allow_versions = false,
|
||||||
$mount_check = false,
|
$mount_check = false,
|
||||||
$account_pipeline = undef,
|
$account_pipeline = undef,
|
||||||
$log_facility = 'LOG_LOCAL2'
|
$log_facility = 'LOG_LOCAL2',
|
||||||
|
$log_level = 'INFO',
|
||||||
|
$log_udp_host = undef,
|
||||||
|
$log_udp_port = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
class { '::swift::storage':
|
class { '::swift::storage':
|
||||||
@@ -68,6 +83,9 @@ class swift::storage::all(
|
|||||||
devices => $devices,
|
devices => $devices,
|
||||||
storage_local_net_ip => $storage_local_net_ip,
|
storage_local_net_ip => $storage_local_net_ip,
|
||||||
mount_check => $mount_check,
|
mount_check => $mount_check,
|
||||||
|
log_level => $log_level,
|
||||||
|
log_udp_host => $log_udp_host,
|
||||||
|
log_udp_port => $log_udp_port,
|
||||||
}
|
}
|
||||||
|
|
||||||
swift::storage::server { $account_port:
|
swift::storage::server { $account_port:
|
||||||
|
@@ -18,6 +18,14 @@
|
|||||||
# *NOTE*: Recommended parameter: 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
|
# *NOTE*: Recommended parameter: 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
|
||||||
# This mask translates to 0755 for directories and 0644 for files.
|
# This mask translates to 0755 for directories and 0644 for files.
|
||||||
#
|
#
|
||||||
|
# [*log_udp_host*]
|
||||||
|
# (optional) If not set, the UDP receiver for syslog is disabled.
|
||||||
|
# Defaults to undef.
|
||||||
|
#
|
||||||
|
# [*log_udp_port*]
|
||||||
|
# (optional) Port value for UDP receiver, if enabled.
|
||||||
|
# Defaults to undef.
|
||||||
|
#
|
||||||
define swift::storage::server(
|
define swift::storage::server(
|
||||||
$type,
|
$type,
|
||||||
$storage_local_net_ip,
|
$storage_local_net_ip,
|
||||||
@@ -39,6 +47,8 @@ define swift::storage::server(
|
|||||||
$log_level = 'INFO',
|
$log_level = 'INFO',
|
||||||
$log_address = '/dev/log',
|
$log_address = '/dev/log',
|
||||||
$log_name = "${type}-server",
|
$log_name = "${type}-server",
|
||||||
|
$log_udp_host = undef,
|
||||||
|
$log_udp_port = undef,
|
||||||
# this parameters needs to be specified after type and name
|
# this parameters needs to be specified after type and name
|
||||||
$config_file_path = "${type}-server/${name}.conf"
|
$config_file_path = "${type}-server/${name}.conf"
|
||||||
) {
|
) {
|
||||||
@@ -60,6 +70,10 @@ define swift::storage::server(
|
|||||||
warning("swift storage server ${type} must specify ${type}-server")
|
warning("swift storage server ${type} must specify ${type}-server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($log_udp_port and !$log_udp_host) {
|
||||||
|
fail ('log_udp_port requires log_udp_host to be set')
|
||||||
|
}
|
||||||
|
|
||||||
include "::swift::storage::${type}"
|
include "::swift::storage::${type}"
|
||||||
include ::concat::setup
|
include ::concat::setup
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ describe 'swift::proxy' do
|
|||||||
'bind_port = 8080',
|
'bind_port = 8080',
|
||||||
"workers = #{facts[:processorcount]}",
|
"workers = #{facts[:processorcount]}",
|
||||||
'user = swift',
|
'user = swift',
|
||||||
'log_name = swift',
|
'log_name = proxy-server',
|
||||||
'log_level = INFO',
|
'log_level = INFO',
|
||||||
'log_headers = False',
|
'log_headers = False',
|
||||||
'log_address = /dev/log',
|
'log_address = /dev/log',
|
||||||
@@ -128,7 +128,73 @@ describe 'swift::proxy' do
|
|||||||
it { is_expected.to contain_concat__fragment('swift_proxy').with_before(
|
it { is_expected.to contain_concat__fragment('swift_proxy').with_before(
|
||||||
'Class[Swift::Proxy::Swauth]'
|
'Class[Swift::Proxy::Swauth]'
|
||||||
)}
|
)}
|
||||||
|
end
|
||||||
|
describe "when log udp port is set" do
|
||||||
|
context 'and log_udp_host is not set' 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_name => 'swift-proxy-server',
|
||||||
|
:log_udp_port => '514',
|
||||||
|
:read_affinity => 'r1z1=100, r1=200',
|
||||||
|
:write_affinity => 'r1',
|
||||||
|
:write_affinity_node_count => '2 * replicas',
|
||||||
|
:node_timeout => '20',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/
|
||||||
|
end
|
||||||
|
context 'and log_udp_host is set' 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_name => 'swift-proxy-server',
|
||||||
|
:log_udp_host => '127.0.0.1',
|
||||||
|
:log_udp_port => '514',
|
||||||
|
:read_affinity => 'r1z1=100, r1=200',
|
||||||
|
:write_affinity => 'r1',
|
||||||
|
:write_affinity_node_count => '2 * replicas',
|
||||||
|
:node_timeout => '20',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it 'should build the header file with provided values' do
|
||||||
|
verify_contents(catalogue, fragment_path,
|
||||||
|
[
|
||||||
|
'[DEFAULT]',
|
||||||
|
'bind_port = 80',
|
||||||
|
"workers = 3",
|
||||||
|
'user = swift',
|
||||||
|
'log_level = DEBUG',
|
||||||
|
'log_udp_host = 127.0.0.1',
|
||||||
|
'log_udp_port = 514',
|
||||||
|
'[pipeline:main]',
|
||||||
|
'pipeline = swauth proxy-server',
|
||||||
|
'[app:proxy-server]',
|
||||||
|
'use = egg:swift#proxy',
|
||||||
|
'set log_name = swift-proxy-server',
|
||||||
|
'allow_account_management = false',
|
||||||
|
'account_autocreate = false',
|
||||||
|
'read_affinity = r1z1=100, r1=200',
|
||||||
|
'write_affinity = r1',
|
||||||
|
'write_affinity_node_count = 2 * replicas',
|
||||||
|
'node_timeout = 20'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'when supplying bad values for parameters' do
|
describe 'when supplying bad values for parameters' do
|
||||||
[:account_autocreate, :allow_account_management].each do |param|
|
[:account_autocreate, :allow_account_management].each do |param|
|
||||||
|
@@ -67,7 +67,7 @@ describe 'swift::storage::server' do
|
|||||||
:user => 'dan',
|
:user => 'dan',
|
||||||
:mount_check => true,
|
:mount_check => true,
|
||||||
:workers => 7,
|
:workers => 7,
|
||||||
:pipeline => ['foo']
|
:pipeline => ['foo'],
|
||||||
}.each do |k,v|
|
}.each do |k,v|
|
||||||
describe "when #{k} is set" do
|
describe "when #{k} is set" do
|
||||||
let :params do req_params.merge({k => v}) end
|
let :params do req_params.merge({k => v}) end
|
||||||
@@ -117,6 +117,20 @@ describe 'swift::storage::server' do
|
|||||||
it { is_expected.to contain_file(fragment_file).with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m)}
|
it { is_expected.to contain_file(fragment_file).with_content(/\[app:container-server\]\nallow_versions\s*=\s*false\s*$/m)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
describe "when log_udp_port is set" do
|
||||||
|
context 'and log_udp_host is not set' do
|
||||||
|
let :params do req_params.merge({ :log_udp_port => 514}) end
|
||||||
|
it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/
|
||||||
|
end
|
||||||
|
context 'and log_udp_host is set' do
|
||||||
|
let :params do req_params.merge(
|
||||||
|
{ :log_udp_host => '127.0.0.1',
|
||||||
|
:log_udp_port => '514'})
|
||||||
|
end
|
||||||
|
it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_host\s*=\s*127\.0\.0\.1\s*$/) }
|
||||||
|
it { is_expected.to contain_file(fragment_file).with_content(/^log_udp_port\s*=\s*514\s*$/) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with all allowed defaults' do
|
describe 'with all allowed defaults' do
|
||||||
|
@@ -4,8 +4,19 @@ bind_ip = <%= @storage_local_net_ip %>
|
|||||||
bind_port = <%= @bind_port %>
|
bind_port = <%= @bind_port %>
|
||||||
mount_check = <%= @mount_check %>
|
mount_check = <%= @mount_check %>
|
||||||
user = <%= @user %>
|
user = <%= @user %>
|
||||||
log_facility = <%= @log_facility %>
|
|
||||||
workers = <%= @workers %>
|
workers = <%= @workers %>
|
||||||
|
log_name = <%= @log_name %>
|
||||||
|
log_facility = <%= @log_facility %>
|
||||||
|
log_level = <%= @log_level %>
|
||||||
|
log_address = <%= @log_address %>
|
||||||
|
<% if @log_udp_host -%>
|
||||||
|
# If set, log_udp_host will override log_address
|
||||||
|
log_udp_host = <%= @log_udp_host -%>
|
||||||
|
<% end %>
|
||||||
|
<% if @log_udp_host and @log_udp_port -%>
|
||||||
|
log_udp_port = <%= @log_udp_port -%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
[pipeline:main]
|
[pipeline:main]
|
||||||
pipeline = <%= @pipeline.to_a.join(' ') %>
|
pipeline = <%= @pipeline.to_a.join(' ') %>
|
||||||
|
@@ -4,7 +4,17 @@ bind_ip = <%= @storage_local_net_ip %>
|
|||||||
bind_port = <%= @bind_port %>
|
bind_port = <%= @bind_port %>
|
||||||
mount_check = <%= @mount_check %>
|
mount_check = <%= @mount_check %>
|
||||||
user = <%= @user %>
|
user = <%= @user %>
|
||||||
|
log_name = <%= @log_name %>
|
||||||
log_facility = <%= @log_facility %>
|
log_facility = <%= @log_facility %>
|
||||||
|
log_level = <%= @log_level %>
|
||||||
|
log_address = <%= @log_address %>
|
||||||
|
<% if @log_udp_host -%>
|
||||||
|
# If set, log_udp_host will override log_address
|
||||||
|
log_udp_host = <%= @log_udp_host -%>
|
||||||
|
<% end %>
|
||||||
|
<% if @log_udp_host and @log_udp_port -%>
|
||||||
|
log_udp_port = <%= @log_udp_port -%>
|
||||||
|
<% end %>
|
||||||
workers = <%= @workers %>
|
workers = <%= @workers %>
|
||||||
allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %>
|
allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %>
|
||||||
|
|
||||||
|
@@ -4,7 +4,17 @@ bind_ip = <%= @storage_local_net_ip %>
|
|||||||
bind_port = <%= @bind_port %>
|
bind_port = <%= @bind_port %>
|
||||||
mount_check = <%= @mount_check %>
|
mount_check = <%= @mount_check %>
|
||||||
user = <%= @user %>
|
user = <%= @user %>
|
||||||
|
log_name = <%= @log_name %>
|
||||||
log_facility = <%= @log_facility %>
|
log_facility = <%= @log_facility %>
|
||||||
|
log_level = <%= @log_level %>
|
||||||
|
log_address = <%= @log_address %>
|
||||||
|
<% if @log_udp_host -%>
|
||||||
|
# If set, log_udp_host will override log_address
|
||||||
|
log_udp_host = <%= @log_udp_host -%>
|
||||||
|
<% end %>
|
||||||
|
<% if @log_udp_host and @log_udp_port -%>
|
||||||
|
log_udp_port = <%= @log_udp_port -%>
|
||||||
|
<% end %>
|
||||||
workers = <%= @workers %>
|
workers = <%= @workers %>
|
||||||
|
|
||||||
[pipeline:main]
|
[pipeline:main]
|
||||||
|
@@ -7,16 +7,16 @@ bind_ip = <%= @proxy_local_net_ip %>
|
|||||||
<% end %>
|
<% end %>
|
||||||
workers = <%= @workers %>
|
workers = <%= @workers %>
|
||||||
user = swift
|
user = swift
|
||||||
log_name = swift
|
log_name = <%= @log_name %>
|
||||||
log_facility = <%= @log_facility %>
|
log_facility = <%= @log_facility %>
|
||||||
log_level = <%= @log_level %>
|
log_level = <%= @log_level %>
|
||||||
log_headers = <%= @log_headers %>
|
log_headers = <%= @log_headers %>
|
||||||
log_address = <%= @log_address %>
|
log_address = <%= @log_address %>
|
||||||
<% if @log_udp_host != '' -%>
|
<% if @log_udp_host -%>
|
||||||
# If set, log_udp_host will override log_address
|
# If set, log_udp_host will override log_address
|
||||||
log_udp_host = <%= @log_udp_host -%>
|
log_udp_host = <%= @log_udp_host -%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @log_udp_host !='' and @log_udp_port != '' -%>
|
<% if @log_udp_host and @log_udp_port -%>
|
||||||
log_udp_port = <%= @log_udp_port -%>
|
log_udp_port = <%= @log_udp_port -%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user