From c2bb2fb31ee4c5a23fe4a218f195da2699fdfe06 Mon Sep 17 00:00:00 2001 From: "Benedikt von St. Vieth" Date: Fri, 4 Sep 2015 20:39:01 +0200 Subject: [PATCH] provide means to disable log_requests in config templates it is hard coded into account, object and container config templates to log every request. Provide a means to disable log_requests via swift::storage::server and swift::storage::all, this reduces the log output. Change-Id: I2fd97c1406710bb0305955f8ff9b47f91c09e13d Closes-Bug: #1484614 --- manifests/storage/all.pp | 9 +++++++++ manifests/storage/server.pp | 6 ++++++ spec/classes/swift_storage_all_spec.rb | 4 +++- spec/defines/swift_storage_server_spec.rb | 10 +++++++++- templates/account-server.conf.erb | 2 +- templates/container-server.conf.erb | 2 +- templates/object-server.conf.erb | 2 +- 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/manifests/storage/all.pp b/manifests/storage/all.pp index 47820269..bc20a6e7 100644 --- a/manifests/storage/all.pp +++ b/manifests/storage/all.pp @@ -58,6 +58,11 @@ # (optional) Port value for UDP receiver, if enabled. # Defaults to undef. # +# [*log_requests*] +# (optional) Whether or not log every request. reduces logging output if false, +# good for seeing errors if true +# Defaults to true. +# # [*incoming_chmod*] Incoming chmod to set in the rsync server. # Optional. Defaults to 0644 for maintaining backwards compatibility. # *NOTE*: Recommended parameter: 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r' @@ -83,6 +88,7 @@ class swift::storage::all( $log_level = 'INFO', $log_udp_host = undef, $log_udp_port = undef, + $log_requests = true, $incoming_chmod = '0644', $outgoing_chmod = '0644', ) { @@ -105,6 +111,7 @@ class swift::storage::all( config_file_path => 'account-server.conf', pipeline => $account_pipeline, log_facility => $log_facility, + log_requests => $log_requests, incoming_chmod => $incoming_chmod, outgoing_chmod => $outgoing_chmod, } @@ -115,6 +122,7 @@ class swift::storage::all( pipeline => $container_pipeline, log_facility => $log_facility, allow_versions => $allow_versions, + log_requests => $log_requests, incoming_chmod => $incoming_chmod, outgoing_chmod => $outgoing_chmod, } @@ -124,6 +132,7 @@ class swift::storage::all( config_file_path => 'object-server.conf', pipeline => $object_pipeline, log_facility => $log_facility, + log_requests => $log_requests, incoming_chmod => $incoming_chmod, outgoing_chmod => $outgoing_chmod, } diff --git a/manifests/storage/server.pp b/manifests/storage/server.pp index 5f271aba..3b6d2deb 100644 --- a/manifests/storage/server.pp +++ b/manifests/storage/server.pp @@ -102,6 +102,11 @@ # (optional) Port value for UDP receiver, if enabled. # Defaults to undef. # +# [*log_requests*] +# (optional) Whether or not log every request. reduces logging output if false, +# good for seeing errors if true +# Defaults to true. +# # [*config_file_path*] # (optional) The configuration file name. # Defaults to "${type}-server/${name}.conf". @@ -129,6 +134,7 @@ define swift::storage::server( $log_name = "${type}-server", $log_udp_host = undef, $log_udp_port = undef, + $log_requests = true, # this parameters needs to be specified after type and name $config_file_path = "${type}-server/${name}.conf" ) { diff --git a/spec/classes/swift_storage_all_spec.rb b/spec/classes/swift_storage_all_spec.rb index 568a034b..34a64cca 100644 --- a/spec/classes/swift_storage_all_spec.rb +++ b/spec/classes/swift_storage_all_spec.rb @@ -22,7 +22,8 @@ describe 'swift::storage::all' do :account_port => '6002', :log_facility => 'LOG_LOCAL2', :incoming_chmod => '0644', - :outgoing_chmod => '0644' + :outgoing_chmod => '0644', + :log_requests => true } end @@ -44,6 +45,7 @@ describe 'swift::storage::all' do :log_facility => ['LOG_LOCAL2', 'LOG_LOCAL3'], :incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', :outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + :log_requests => false } ].each do |param_set| diff --git a/spec/defines/swift_storage_server_spec.rb b/spec/defines/swift_storage_server_spec.rb index 60558b03..c89a9b58 100644 --- a/spec/defines/swift_storage_server_spec.rb +++ b/spec/defines/swift_storage_server_spec.rb @@ -21,7 +21,8 @@ describe 'swift::storage::server' do :group => 'swift', :incoming_chmod => '0644', :outgoing_chmod => '0644', - :max_connections => '25' + :max_connections => '25', + :log_requests => true } end @@ -142,6 +143,12 @@ describe 'swift::storage::server' do end it { is_expected.to contain_concat("/etc/swift/#{t}-server/#{title}.conf").that_comes_before("Swift_#{t}_config[foo/bar]") } end + describe "when log_requests is turned off" do + let :params do req_params.merge({:log_requests => false}) end + it { is_expected.to contain_file(fragment_file) \ + .with_content(/^set log_requests\s*=\s*false\s*$/) + } + end end describe 'with all allowed defaults' do @@ -170,6 +177,7 @@ describe 'swift::storage::server' do it { is_expected.to contain_file(fragment_file).with_content(/^set log_facility\s*=\s*LOG_LOCAL2\s*$/) } it { is_expected.to contain_file(fragment_file).with_content(/^set log_level\s*=\s*INFO\s*$/) } it { is_expected.to contain_file(fragment_file).with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) } + it { is_expected.to contain_file(fragment_file).with_content(/^set log_requests\s*=\s*true\s*$/) } it { is_expected.to contain_file(fragment_file).with_content(/^workers\s*=\s*1\s*$/) } it { is_expected.to contain_file(fragment_file).with_content(/^concurrency\s*=\s*1\s*$/) } it { is_expected.to contain_file(fragment_file).with_content(/^pipeline\s*=\s*#{t}-server\s*$/) } diff --git a/templates/account-server.conf.erb b/templates/account-server.conf.erb index 7fd7094d..6c4ba277 100644 --- a/templates/account-server.conf.erb +++ b/templates/account-server.conf.erb @@ -25,7 +25,7 @@ use = egg:swift#account set log_name = <%= @log_name %> set log_facility = <%= @log_facility %> set log_level = <%= @log_level %> -set log_requests = True +set log_requests = <%= @log_requests %> set log_address = <%= @log_address %> [account-replicator] diff --git a/templates/container-server.conf.erb b/templates/container-server.conf.erb index eee15a30..fa05fd0d 100644 --- a/templates/container-server.conf.erb +++ b/templates/container-server.conf.erb @@ -27,7 +27,7 @@ use = egg:swift#container set log_name = <%= @log_name %> set log_facility = <%= @log_facility %> set log_level = <%= @log_level %> -set log_requests = True +set log_requests = <%= @log_requests %> set log_address = <%= @log_address %> [container-replicator] diff --git a/templates/object-server.conf.erb b/templates/object-server.conf.erb index 0ebe68c8..e5d79227 100644 --- a/templates/object-server.conf.erb +++ b/templates/object-server.conf.erb @@ -25,7 +25,7 @@ use = egg:swift#object set log_name = <%= @log_name %> set log_facility = <%= @log_facility %> set log_level = <%= @log_level %> -set log_requests = True +set log_requests = <%= @log_requests %> set log_address = <%= @log_address %> [object-replicator]