Add until_complete to archive_deleted_rows.pp
Add a boolean flag to clean the all the deleted instances. Will run in batches of max_rows until empty. Change-Id: I927b75adb0fc3251f3734d41f4393590294c1c9b
This commit is contained in:
parent
4801dd0ce3
commit
24003c8847
@ -49,6 +49,10 @@
|
||||
# (optional) Path to file to which rows should be archived
|
||||
# Defaults to '/var/log/nova/nova-rowsflush.log'.
|
||||
#
|
||||
# [*until_complete*]
|
||||
# (optional) Adds --until_complete to the archive command
|
||||
# Defaults to false.
|
||||
#
|
||||
class nova::cron::archive_deleted_rows (
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
@ -57,13 +61,18 @@ class nova::cron::archive_deleted_rows (
|
||||
$weekday = '*',
|
||||
$max_rows = '100',
|
||||
$user = 'nova',
|
||||
$destination = '/var/log/nova/nova-rowsflush.log'
|
||||
$destination = '/var/log/nova/nova-rowsflush.log',
|
||||
$until_complete = false,
|
||||
) {
|
||||
|
||||
include ::nova::deps
|
||||
|
||||
if $until_complete {
|
||||
$until_complete_real = '--until_complete'
|
||||
}
|
||||
|
||||
cron { 'nova-manage db archive_deleted_rows':
|
||||
command => "nova-manage db archive_deleted_rows --max_rows ${max_rows} >>${destination} 2>&1",
|
||||
command => "nova-manage db archive_deleted_rows --max_rows ${max_rows} ${until_complete_real} >>${destination} 2>&1",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
user => $user,
|
||||
minute => $minute,
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- Adds --until_complete to the archive command
|
||||
based on an empty_table boolean flag.
|
||||
If true, it will run in batches of max_rows
|
||||
until the table is empty.
|
@ -111,7 +111,7 @@ describe 'basic nova' do
|
||||
end
|
||||
|
||||
describe cron do
|
||||
it { is_expected.to have_entry('1 0 * * * nova-manage db archive_deleted_rows --max_rows 100 >>/var/log/nova/nova-rowsflush.log 2>&1').with_user('nova') }
|
||||
it { is_expected.to have_entry('1 0 * * * nova-manage db archive_deleted_rows --max_rows 100 >>/var/log/nova/nova-rowsflush.log 2>&1').with_user('nova') }
|
||||
end
|
||||
|
||||
describe 'nova aggregate' do
|
||||
|
@ -7,28 +7,52 @@ describe 'nova::cron::archive_deleted_rows' do
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*',
|
||||
:max_rows => '100',
|
||||
:user => 'nova',
|
||||
:destination => '/var/log/nova/nova-rowsflush.log' }
|
||||
{ :minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*',
|
||||
:max_rows => '100',
|
||||
:user => 'nova',
|
||||
:until_complete => false,
|
||||
:destination => '/var/log/nova/nova-rowsflush.log' }
|
||||
end
|
||||
|
||||
it 'configures a cron' do
|
||||
is_expected.to contain_cron('nova-manage db archive_deleted_rows').with(
|
||||
:command => "nova-manage db archive_deleted_rows --max_rows #{params[:max_rows]} >>#{params[:destination]} 2>&1",
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => params[:user],
|
||||
:minute => params[:minute],
|
||||
:hour => params[:hour],
|
||||
:monthday => params[:monthday],
|
||||
:month => params[:month],
|
||||
:weekday => params[:weekday],
|
||||
:require => 'Anchor[nova::dbsync::end]',
|
||||
)
|
||||
context 'until_complete is false' do
|
||||
it 'configures a cron without until_complete' do
|
||||
is_expected.to contain_cron('nova-manage db archive_deleted_rows').with(
|
||||
:command => "nova-manage db archive_deleted_rows --max_rows #{params[:max_rows]} >>#{params[:destination]} 2>&1",
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => params[:user],
|
||||
:minute => params[:minute],
|
||||
:hour => params[:hour],
|
||||
:monthday => params[:monthday],
|
||||
:month => params[:month],
|
||||
:weekday => params[:weekday],
|
||||
:require => 'Anchor[nova::dbsync::end]',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'until_complete is true' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
:until_complete => true,
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures a cron with until_complete' do
|
||||
is_expected.to contain_cron('nova-manage db archive_deleted_rows').with(
|
||||
:command => "nova-manage db archive_deleted_rows --max_rows #{params[:max_rows]} --until_complete >>#{params[:destination]} 2>&1",
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => params[:user],
|
||||
:minute => params[:minute],
|
||||
:hour => params[:hour],
|
||||
:monthday => params[:monthday],
|
||||
:month => params[:month],
|
||||
:weekday => params[:weekday],
|
||||
:require => 'Anchor[nova::dbsync::end]',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user