Allow configuration of limit of batch size for exirer

Adds new configuration option for panko-expirer for limiting detele
batch size.

Change-Id: I7ca0ab9e42352645e463c49f8ce58793115543c0
(cherry picked from commit 89c3f384f0)
This commit is contained in:
Martin Magr 2020-09-23 11:17:17 +02:00 committed by Takashi Kajinami
parent 4712c01716
commit c954ebf149
3 changed files with 34 additions and 6 deletions

View File

@ -25,13 +25,18 @@
# [*weekday*] # [*weekday*]
# (optional) Defaults to '*'. # (optional) Defaults to '*'.
# #
# [*events_delete_batch_size*]
# (optional) Limit number of deleted events in single purge run.
# Defaults to $::os_service_default.
#
class panko::expirer ( class panko::expirer (
$enable_cron = true, $enable_cron = true,
$minute = 1, $minute = 1,
$hour = 0, $hour = 0,
$monthday = '*', $monthday = '*',
$month = '*', $month = '*',
$weekday = '*', $weekday = '*',
$events_delete_batch_size = $::os_service_default,
) { ) {
include panko::params include panko::params
@ -45,6 +50,10 @@ class panko::expirer (
$ensure = 'absent' $ensure = 'absent'
} }
panko_config { 'database/events_delete_batch_size':
value => $events_delete_batch_size
}
cron { 'panko-expirer': cron { 'panko-expirer':
ensure => $ensure, ensure => $ensure,
command => $panko::params::expirer_command, command => $panko::params::expirer_command,

View File

@ -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.

View File

@ -9,6 +9,7 @@ describe 'panko::expirer' do
context 'with default' do context 'with default' do
it { is_expected.to contain_class('panko::deps') } it { is_expected.to contain_class('panko::deps') }
it { is_expected.to contain_class('panko::params') } it { is_expected.to contain_class('panko::params') }
it { is_expected.to contain_panko_config('database/events_delete_batch_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_cron('panko-expirer').with( it { is_expected.to contain_cron('panko-expirer').with(
:ensure => 'present', :ensure => 'present',
@ -23,6 +24,18 @@ describe 'panko::expirer' do
)} )}
end end
context 'with overridden parameters' do
before do
params.merge!(
: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) }
end
context 'with cron not enabled' do context 'with cron not enabled' do
before do before do
params.merge!( :enable_cron => false ) params.merge!( :enable_cron => false )