Add glance-cache-cleaner and glance-cache-pruner
* glance::cache::cleaner: Installs a cron job to remove stalled and invalid cached images. * glance::cache::pruner: Installs a cron job to keep the image cache at or below the maximum cache size. Change-Id: I99cb1809446f1a1126454ff5fa5bdceb8044ee28
This commit is contained in:
parent
67790ef1d4
commit
7da1f3bf2d
42
manifests/cache/cleaner.pp
vendored
Normal file
42
manifests/cache/cleaner.pp
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# == Class: glance::cache::cleaner
|
||||
#
|
||||
# Installs a cron job to run glance-cache-cleaner.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*minute*]
|
||||
# (optional) Defaults to '1'.
|
||||
#
|
||||
# [*hour*]
|
||||
# (optional) Defaults to '0'.
|
||||
#
|
||||
# [*monthday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*month*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
class glance::cache::cleaner (
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
) {
|
||||
|
||||
include glance::params
|
||||
|
||||
cron { 'glance-cache-cleaner':
|
||||
command => $glance::params::cache_cleaner_command,
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
user => 'glance',
|
||||
minute => $minute,
|
||||
hour => $hour,
|
||||
monthday => $monthday,
|
||||
month => $month,
|
||||
weekday => $weekday
|
||||
}
|
||||
}
|
42
manifests/cache/pruner.pp
vendored
Normal file
42
manifests/cache/pruner.pp
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# == Class: glance::cache::pruner
|
||||
#
|
||||
# Installs a cron job to run glance-cache-pruner.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*minute*]
|
||||
# (optional) Defaults to '*/30'.
|
||||
#
|
||||
# [*hour*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*monthday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*month*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
class glance::cache::pruner (
|
||||
$minute = '*/30',
|
||||
$hour = '*',
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
) {
|
||||
|
||||
include glance::params
|
||||
|
||||
cron { 'glance-cache-pruner':
|
||||
command => $glance::params::cache_pruner_command,
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
user => 'glance',
|
||||
minute => $minute,
|
||||
hour => $hour,
|
||||
monthday => $monthday,
|
||||
month => $month,
|
||||
weekday => $weekday
|
||||
}
|
||||
}
|
@ -5,6 +5,9 @@ class glance::params {
|
||||
$client_package_name = 'python-glanceclient'
|
||||
$pyceph_package_name = 'python-ceph'
|
||||
|
||||
$cache_cleaner_command = 'glance-cache-cleaner'
|
||||
$cache_pruner_command = 'glance-cache-pruner'
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$package_name = 'openstack-glance'
|
||||
|
21
spec/classes/glance_cache_cleaner_spec.rb
Normal file
21
spec/classes/glance_cache_cleaner_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::cache::cleaner' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it 'configures a cron' do
|
||||
should contain_cron('glance-cache-cleaner').with(
|
||||
:command => 'glance-cache-cleaner',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
:user => 'glance',
|
||||
:minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*'
|
||||
)
|
||||
end
|
||||
end
|
21
spec/classes/glance_cache_pruner_spec.rb
Normal file
21
spec/classes/glance_cache_pruner_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::cache::pruner' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it 'configures a cron' do
|
||||
should contain_cron('glance-cache-pruner').with(
|
||||
:command => 'glance-cache-pruner',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
:user => 'glance',
|
||||
:minute => '*/30',
|
||||
:hour => '*',
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*'
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user