Allow customizing status of cron job
... so that users can even remove the job. This follows what was added to puppet-nova by [1]. [1] https://review.opendev.org/c/openstack/puppet-nova/+/877096 Change-Id: I53ed7dbf376d71024eec589e475cbd5e75162d8e
This commit is contained in:
parent
11f96e6c12
commit
7a9fc8e8cf
@ -57,6 +57,10 @@
|
||||
# all cron jobs at the same time on all hosts this job is configured.
|
||||
# Defaults to 0.
|
||||
#
|
||||
# [*ensure*]
|
||||
# (optional) Ensure cron jobs present or absent
|
||||
# Defaults to present.
|
||||
#
|
||||
class cinder::cron::db_purge (
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
@ -66,7 +70,8 @@ class cinder::cron::db_purge (
|
||||
$user = 'cinder',
|
||||
$age = 30,
|
||||
$destination = '/var/log/cinder/cinder-rowsflush.log',
|
||||
$maxdelay = 0
|
||||
$maxdelay = 0,
|
||||
Enum['present', 'absent'] $ensure = 'present',
|
||||
) {
|
||||
|
||||
include cinder::deps
|
||||
@ -78,6 +83,7 @@ class cinder::cron::db_purge (
|
||||
}
|
||||
|
||||
cron { 'cinder-manage db purge':
|
||||
ensure => $ensure,
|
||||
command => "${sleep}cinder-manage db purge ${age} >>${destination} 2>&1",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
user => $user,
|
||||
|
5
releasenotes/notes/cron-ensure-bd3b9d51d459ffbe.yaml
Normal file
5
releasenotes/notes/cron-ensure-bd3b9d51d459ffbe.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``cinder::cron::db_purge::ensure`` parameter has been added, so
|
||||
that status of the cron job can be customized.
|
@ -18,6 +18,7 @@ describe 'cinder::cron::db_purge' do
|
||||
shared_examples 'cinder::cron::db_purge' do
|
||||
context 'with required parameters' do
|
||||
it { is_expected.to contain_cron('cinder-manage db purge').with(
|
||||
:ensure => :present,
|
||||
:command => "cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => params[:user],
|
||||
@ -30,6 +31,16 @@ describe 'cinder::cron::db_purge' do
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with ensure set to absent' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
:ensure => :absent
|
||||
)
|
||||
end
|
||||
|
||||
it { should contain_cron('cinder-manage db purge').with_ensure(:absent) }
|
||||
end
|
||||
|
||||
context 'with required parameters with max delay enabled' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
@ -38,6 +49,7 @@ describe 'cinder::cron::db_purge' do
|
||||
end
|
||||
|
||||
it { should contain_cron('cinder-manage db purge').with(
|
||||
:ensure => :present,
|
||||
:command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => params[:user],
|
||||
|
Loading…
Reference in New Issue
Block a user