Fix karaf log rotation 80/75480/7
authorVictor Pickard <vpickard@redhat.com>
Fri, 24 Aug 2018 19:31:27 +0000 (15:31 -0400)
committerVictor Pickard <vpickard@redhat.com>
Mon, 24 Sep 2018 17:16:43 +0000 (13:16 -0400)
Missing a config parm for this to work as desired.

Details in the JIRA.

JIRA INTPAK-199

Change-Id: I0776713d541bf6774da2ea8ee50e8bc6db42cb45
Signed-off-by: Victor Pickard <vpickard@redhat.com>
CHANGELOG
README.markdown
manifests/config.pp
manifests/init.pp
manifests/params.pp
metadata.json
spec/acceptance/class_spec.rb
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index 0347d416178e8ad95d0b16d0057c7c2da7829884..36fb52a76821ed58aa581404c3f8ac85a665060e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -82,3 +82,5 @@
 - Disable regular polling of OF statistics
 2018-07-23 Release 8.4.0
 - Enable IPv6 deployment
+2018-09-18 Release 8.4.1
+- Fix opendaylight karaf log file rotation
index 1c7f932e2948ff9b214299ea76083b3e0bf5de23..21b9686e8c758dca1199fded6a2a4e7bbe7ae00f 100644 (file)
@@ -323,6 +323,24 @@ Default: `2`
 
 Valid options: An integer greater than 0.
 
+##### `log_rollover_fileindex`
+
+String that controls file index to use when log rollovers are initiated.
+
+If set to 'max', files with a higher index will be newer than files with
+a smaller index.
+
+If set to 'min', file with a lower index will be newer than files with a
+higher index.
+
+If set to 'nomax', the min and max values will be ignored, and file
+numbering will increment by 1 and each rollover will have an
+incrementally higher value with no maximum number of files.
+
+Default: `min`
+
+Valid options: 'min', 'max', 'nomax'
+
 ##### `log_mechanism`
 
 Logging mechanism for karaf logs. They are logged either to a file or console.
index ebf9cc3f1cac682414dcc81620974a4918d059a2..fba6e55c0c203e3bc3b8c722db873f7683b558e8 100644 (file)
@@ -276,6 +276,14 @@ class opendaylight::config {
       line   => "log4j2.appender.rolling.strategy.max = ${::opendaylight::log_max_rollover}",
       match  => '^log4j2.appender.rolling.strategy.max.*$'
     }
+
+    # Set file index to min for rollover strategy
+    -> file_line { 'logrolloverfileindex':
+      ensure => present,
+      path   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      line   => "log4j2.appender.rolling.strategy.fileIndex = ${::opendaylight::log_rollover_fileindex}",
+      match  => '^log4j2.appender.rolling.strategy.fileIndex.*$'
+    }
   }
 
   # Configure ODL HA if enabled
index 42ef3272cc339a70123299780714ff5880e4d458..e80bc5aee259cb156e8a129cb0b923bd69b74fec 100644 (file)
 #   Maxium size of OpenDaylight's log file.
 # [*log_max_rollover*]
 #   Maxium number of OpenDaylight log rollovers to keep.
+# [*log_rollover_fileindex*]
+#   File index to use for OpenDaylight log rollovers
+#   Defaults to 'min'.
+#   Other possible values: 'max', 'nomax'
+#   see https://logging.apache.org/log4j/2.x/manual/appenders.html#FileAppender for more info
 # [*snat_mechanism*]
 #   Sets the mechanism to be used for SNAT (conntrack, controller)
 # [*enable_tls*]
 #   Index of ha_node_ips for this node.
 #
 class opendaylight (
-  $default_features      = $::opendaylight::params::default_features,
-  $extra_features        = $::opendaylight::params::extra_features,
-  $odl_rest_port         = $::opendaylight::params::odl_rest_port,
-  $odl_bind_ip           = $::opendaylight::params::odl_bind_ip,
-  $rpm_repo              = $::opendaylight::params::rpm_repo,
-  $deb_repo              = $::opendaylight::params::deb_repo,
-  $log_levels            = $::opendaylight::params::log_levels,
-  $enable_ha             = $::opendaylight::params::enable_ha,
-  $ha_node_ips           = $::opendaylight::params::ha_node_ips,
-  $ha_node_index         = $::opendaylight::params::ha_node_index,
-  $java_opts             = $::opendaylight::params::java_opts,
-  $ha_db_modules         = $::opendaylight::params::ha_db_modules,
-  $vpp_routing_node      = $::opendaylight::params::vpp_routing_node,
-  $manage_repositories   = $::opendaylight::params::manage_repositories,
-  $username              = $::opendaylight::params::username,
-  $password              = $::opendaylight::params::password,
-  $log_max_size          = $::opendaylight::params::log_max_size,
-  $log_max_rollover      = $::opendaylight::params::log_max_rollover,
-  $snat_mechanism        = $::opendaylight::params::snat_mechanism,
-  $enable_tls            = $::opendaylight::params::enable_tls,
-  $tls_keystore_password = $::opendaylight::params::tls_keystore_password,
-  $tls_trusted_certs     = $::opendaylight::params::tls_trusted_certs,
-  $tls_key_file          = $::opendaylight::params::tls_key_file,
-  $tls_cert_file         = $::opendaylight::params::tls_cert_file,
-  $tls_ca_cert_file      = $::opendaylight::params::tls_ca_cert_file,
-  $log_mechanism         = $::opendaylight::params::log_mechanism,
-  $inherit_dscp_marking  = $::opendaylight::params::inherit_dscp_marking,
-  $stats_polling_enabled = $::opendaylight::params::stats_polling_enabled,
+  $default_features       = $::opendaylight::params::default_features,
+  $extra_features         = $::opendaylight::params::extra_features,
+  $odl_rest_port          = $::opendaylight::params::odl_rest_port,
+  $odl_bind_ip            = $::opendaylight::params::odl_bind_ip,
+  $rpm_repo               = $::opendaylight::params::rpm_repo,
+  $deb_repo               = $::opendaylight::params::deb_repo,
+  $log_levels             = $::opendaylight::params::log_levels,
+  $enable_ha              = $::opendaylight::params::enable_ha,
+  $ha_node_ips            = $::opendaylight::params::ha_node_ips,
+  $ha_node_index          = $::opendaylight::params::ha_node_index,
+  $java_opts              = $::opendaylight::params::java_opts,
+  $ha_db_modules          = $::opendaylight::params::ha_db_modules,
+  $vpp_routing_node       = $::opendaylight::params::vpp_routing_node,
+  $manage_repositories    = $::opendaylight::params::manage_repositories,
+  $username               = $::opendaylight::params::username,
+  $password               = $::opendaylight::params::password,
+  $log_max_size           = $::opendaylight::params::log_max_size,
+  $log_max_rollover       = $::opendaylight::params::log_max_rollover,
+  $log_rollover_fileindex = $::opendaylight::params::log_rollover_fileindex,
+  $snat_mechanism         = $::opendaylight::params::snat_mechanism,
+  $enable_tls             = $::opendaylight::params::enable_tls,
+  $tls_keystore_password  = $::opendaylight::params::tls_keystore_password,
+  $tls_trusted_certs      = $::opendaylight::params::tls_trusted_certs,
+  $tls_key_file           = $::opendaylight::params::tls_key_file,
+  $tls_cert_file          = $::opendaylight::params::tls_cert_file,
+  $tls_ca_cert_file       = $::opendaylight::params::tls_ca_cert_file,
+  $log_mechanism          = $::opendaylight::params::log_mechanism,
+  $inherit_dscp_marking   = $::opendaylight::params::inherit_dscp_marking,
+  $stats_polling_enabled  = $::opendaylight::params::stats_polling_enabled,
 ) inherits ::opendaylight::params {
 
   # Validate OS family
index 9b2acd5466e6610e7a769ed70d75378e81b066fa..9bbcde1ca5df346bef6b8aca549dae1ffacd4697 100644 (file)
@@ -26,6 +26,7 @@ class opendaylight::params {
   $password = 'admin'
   $log_max_size = '10GB'
   $log_max_rollover = 2
+  $log_rollover_fileindex = 'min'
   $snat_mechanism = 'controller'
   $enable_tls = false
   $tls_keystore_password = undef
index 1db9942459d5278ad2d49fa94efa55e3163ba343..667feaceb924426bcbdd1529890872667a1a3b70 100644 (file)
@@ -1,6 +1,6 @@
 {
     "name": "opendaylight-opendaylight",
-    "version": "8.4.0",
+    "version": "8.4.1",
     "author": "Daniel Farrell",
     "summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
     "license": "BSD-2-Clause",
index a233f343790401766bd799b7c7ac0be22a99dad7..b45ad38b50fafec29c1d9f2bd56e42bcafc46945 100644 (file)
@@ -102,11 +102,13 @@ describe 'opendaylight class' do
     context 'log to file customising size and rollover' do
       # Call specialized helper fn to install OpenDaylight
       install_odl(log_max_size: '1GB',
-                  log_max_rollover: 3)
+                  log_max_rollover: 3,
+                  log_rollover_fileIndex: 'min')
 
       # Call specialized helper fn for log settings validations
       log_settings_validations(log_max_size: '1GB',
-                                    log_max_rollover: 3)
+                               log_max_rollover: 3,
+                               log_rollover_fileIndex: 'min')
     end
 
     context 'log to console' do
index 98ab84dc33de3bf541674b0a96443ed90451ffb9..7013d2204f992616e1742ad517cd2f4deeb0bf50 100644 (file)
@@ -519,6 +519,7 @@ describe 'opendaylight' do
       let(:params) {{
         :log_max_size => '1GB',
         :log_max_rollover => 3,
+        :log_rollover_fileindex => 'min'
       }}
 
       # Run shared tests applicable to all supported OSs
@@ -527,7 +528,8 @@ describe 'opendaylight' do
 
       # Run test specific to log settings
       log_settings(log_max_size: '1GB',
-                        log_max_rollover: 3)
+                   log_max_rollover: 3,
+                   log_rollover_fileindex: 'min')
     end
 
     context 'log to console' do
index f17990ea3b2564c9d142e667b437b342613ed643..06dbf1cb5d474f427ae418c0dfacf41078164e77 100644 (file)
@@ -86,6 +86,7 @@ def log_settings(options = {})
   # Extraxt params. The dafault value should be same as in opendaylight::params
   log_max_size = options.fetch(:log_max_size, '10GB')
   log_max_rollover = options.fetch(:log_max_rollover, 2)
+  log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
   log_mechanism = options.fetch(:log_mechanism, 'file')
 
   if log_mechanism == 'console'
@@ -127,6 +128,13 @@ def log_settings(options = {})
         'match'  => '^log4j2.appender.rolling.strategy.max.*$',
       )
     }
+    it {
+      should contain_file_line('logrolloverfileindex').with(
+        'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+        'line'   => "log4j2.appender.rolling.strategy.fileIndex = #{log_rollover_fileindex}",
+        'match'  => '^log4j2.appender.rolling.strategy.fileIndex.*$',
+      )
+    }
   end
 end
 
index 86b43645fb79b30947360d89d5e23ed8685da3a0..339ed420faa50b3e5fc7c6866df0f3f31a1d8ac8 100644 (file)
@@ -69,6 +69,7 @@ def install_odl(options = {})
   password = options.fetch(:password, 'admin')
   log_max_size = options.fetch(:log_max_size, '10GB')
   log_max_rollover = options.fetch(:log_max_rollover, 2)
+  log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
   snat_mechanism = options.fetch(:snat_mechanism, 'controller')
   enable_tls = options.fetch(:enable_tls, false)
   tls_keystore_password = options.fetch(:tls_keystore_password, 'dummypass')
@@ -95,6 +96,7 @@ def install_odl(options = {})
       password => #{password},
       log_max_size => '#{log_max_size}',
       log_max_rollover => #{log_max_rollover},
+      log_rollover_fileindex => #{log_rollover_fileindex},
       snat_mechanism => #{snat_mechanism},
       enable_tls => #{enable_tls},
       tls_keystore_password => #{tls_keystore_password},
@@ -240,6 +242,7 @@ def log_settings_validations(options = {})
   # Should contain log level config file with correct file size and rollover values
   log_max_size = options.fetch(:log_max_size, '10GB')
   log_max_rollover = options.fetch(:log_max_rollover, 2)
+  log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
   log_mechanism = options.fetch(:log_mechanism, 'file')
 
   if log_mechanism == 'console'
@@ -258,6 +261,7 @@ def log_settings_validations(options = {})
       its(:content) { should match /^log4j2.appender.rolling.policies.size.size = #{log_max_size}/ }
       its(:content) { should match /^log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy/ }
       its(:content) { should match /^log4j2.appender.rolling.strategy.max = #{log_max_rollover}/ }
+      its(:content) { should match /^log4j2.appender.rolling.strategy.fileIndex = #{log_rollover_fileindex}/ }
     end
   end
 end