Add support for aodh-expirer cron job
Change-Id: I8c0e806112b947fccc6b0a6e47c3e0d3722a3e84
This commit is contained in:
parent
1a25a60c01
commit
89da4b14fa
65
manifests/expirer.pp
Normal file
65
manifests/expirer.pp
Normal file
@ -0,0 +1,65 @@
|
||||
#
|
||||
# == Class: aodh::expirer
|
||||
#
|
||||
# Setups Aodh Expirer service to enable TTL feature.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*ensure*]
|
||||
# (optional) The state of cron job.
|
||||
# Defaults to present.
|
||||
#
|
||||
# [*minute*]
|
||||
# (optional) Defaults to '1'.
|
||||
#
|
||||
# [*hour*]
|
||||
# (optional) Defaults to '0'.
|
||||
#
|
||||
# [*monthday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*month*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*maxdelay*]
|
||||
# (optional) In Seconds. Should be a positive integer.
|
||||
# Induces a random delay before running the cronjob to avoid running
|
||||
# all cron jobs at the same time on all hosts this job is configured.
|
||||
# Defaults to 0.
|
||||
#
|
||||
class aodh::expirer (
|
||||
$ensure = 'present',
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$maxdelay = 0,
|
||||
) {
|
||||
|
||||
include aodh::params
|
||||
include aodh::deps
|
||||
|
||||
if $maxdelay == 0 {
|
||||
$sleep = ''
|
||||
} else {
|
||||
$sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; "
|
||||
}
|
||||
|
||||
cron { 'aodh-expirer':
|
||||
ensure => $ensure,
|
||||
command => "${sleep}${aodh::params::expirer_command}",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
user => 'aodh',
|
||||
minute => $minute,
|
||||
hour => $hour,
|
||||
monthday => $monthday,
|
||||
month => $month,
|
||||
weekday => $weekday,
|
||||
require => Anchor['aodh::install::end'],
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ class aodh::params {
|
||||
|
||||
$client_package_name = "python${pyvers}-aodhclient"
|
||||
$group = 'aodh'
|
||||
$expirer_command = 'aodh-expirer'
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
|
5
releasenotes/notes/expirer-a53e68fe61ff3f17.yaml
Normal file
5
releasenotes/notes/expirer-a53e68fe61ff3f17.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``aodh::expirer`` class has been added to support a cron job to run
|
||||
aodh-expirer command.
|
65
spec/classes/aodh_expirer_spec.rb
Normal file
65
spec/classes/aodh_expirer_spec.rb
Normal file
@ -0,0 +1,65 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'aodh::expirer' do
|
||||
shared_examples 'aodh::expirer' do
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
context 'with default' do
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
|
||||
it { is_expected.to contain_cron('aodh-expirer').with(
|
||||
:ensure => 'present',
|
||||
:command => 'aodh-expirer',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => 'aodh',
|
||||
:minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*',
|
||||
:require => 'Anchor[aodh::install::end]'
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
before do
|
||||
params.merge!(
|
||||
:ensure => 'absent',
|
||||
:maxdelay => 300
|
||||
)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
|
||||
it { is_expected.to contain_cron('aodh-expirer').with(
|
||||
:ensure => 'absent',
|
||||
:command => 'sleep `expr ${RANDOM} \\% 300`; aodh-expirer',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => 'aodh',
|
||||
:minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*',
|
||||
:require => 'Anchor[aodh::install::end]'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'aodh::expirer'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user