From 89c3f384f01b778aee6a2c7ce24db226b0fbd770 Mon Sep 17 00:00:00 2001 From: Martin Magr Date: Wed, 23 Sep 2020 11:17:17 +0200 Subject: [PATCH] Allow configuration of limit of batch size for exirer Adds new configuration option for panko-expirer for limiting detele batch size. Change-Id: I7ca0ab9e42352645e463c49f8ce58793115543c0 --- manifests/expirer.pp | 23 +++++++++++++------ .../notes/batchsize-9f201b538828370d.yaml | 6 +++++ spec/classes/panko_expirer_spec.rb | 7 ++++-- 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/batchsize-9f201b538828370d.yaml diff --git a/manifests/expirer.pp b/manifests/expirer.pp index 5e57ef6..1aca4fe 100644 --- a/manifests/expirer.pp +++ b/manifests/expirer.pp @@ -30,6 +30,10 @@ # all cron jobs at the same time on all hosts this job is configured. # Defaults to 0. # +# [*events_delete_batch_size*] +# (optional) Limit number of deleted events in single purge run. +# Defaults to $::os_service_default. +# # DEPRECATED PARAMETERS # # [*enable_cron*] @@ -38,13 +42,14 @@ # Defaults to undef, # class panko::expirer ( - $ensure = 'present', - $minute = 1, - $hour = 0, - $monthday = '*', - $month = '*', - $weekday = '*', - $maxdelay = 0, + $ensure = 'present', + $minute = 1, + $hour = 0, + $monthday = '*', + $month = '*', + $weekday = '*', + $maxdelay = 0, + $events_delete_batch_size = $::os_service_default, # DEPRECATED PARAMETERS $enable_cron = undef, ) { @@ -71,6 +76,10 @@ in a future release. Use panko::expirer::ensure instead') $sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; " } + panko_config { 'database/events_delete_batch_size': + value => $events_delete_batch_size + } + cron { 'panko-expirer': ensure => $ensure_real, command => "${sleep}${panko::params::expirer_command}", diff --git a/releasenotes/notes/batchsize-9f201b538828370d.yaml b/releasenotes/notes/batchsize-9f201b538828370d.yaml new file mode 100644 index 0000000..2a0a83f --- /dev/null +++ b/releasenotes/notes/batchsize-9f201b538828370d.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Added events_delete_batch_size parameter to the expirer class to enable configuration + of the parameter with same name. It serves the purpose of limiting number of deleted + events in single purge run. diff --git a/spec/classes/panko_expirer_spec.rb b/spec/classes/panko_expirer_spec.rb index 1b372ca..59c3bee 100644 --- a/spec/classes/panko_expirer_spec.rb +++ b/spec/classes/panko_expirer_spec.rb @@ -9,6 +9,7 @@ describe 'panko::expirer' do context 'with default' do it { is_expected.to contain_class('panko::deps') } it { is_expected.to contain_class('panko::params') } + it { is_expected.to contain_panko_config('database/events_delete_batch_size').with_value('') } it { is_expected.to contain_cron('panko-expirer').with( :ensure => 'present', @@ -27,13 +28,15 @@ describe 'panko::expirer' do context 'with overridden parameters' do before do params.merge!( - :ensure => 'absent', - :maxdelay => 300 + :ensure => 'absent', + :maxdelay => 300, + :events_delete_batch_size => 500 ) end it { is_expected.to contain_class('panko::deps') } it { is_expected.to contain_class('panko::params') } + it { is_expected.to contain_panko_config('database/events_delete_batch_size').with_value(500) } it { is_expected.to contain_cron('panko-expirer').with( :ensure => 'absent',