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
|
# (optional) Path to file to which rows should be archived
|
||||||
# Defaults to '/var/log/nova/nova-rowsflush.log'.
|
# 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 (
|
class nova::cron::archive_deleted_rows (
|
||||||
$minute = 1,
|
$minute = 1,
|
||||||
$hour = 0,
|
$hour = 0,
|
||||||
|
@ -57,13 +61,18 @@ class nova::cron::archive_deleted_rows (
|
||||||
$weekday = '*',
|
$weekday = '*',
|
||||||
$max_rows = '100',
|
$max_rows = '100',
|
||||||
$user = 'nova',
|
$user = 'nova',
|
||||||
$destination = '/var/log/nova/nova-rowsflush.log'
|
$destination = '/var/log/nova/nova-rowsflush.log',
|
||||||
|
$until_complete = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include ::nova::deps
|
include ::nova::deps
|
||||||
|
|
||||||
|
if $until_complete {
|
||||||
|
$until_complete_real = '--until_complete'
|
||||||
|
}
|
||||||
|
|
||||||
cron { 'nova-manage db archive_deleted_rows':
|
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',
|
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
user => $user,
|
user => $user,
|
||||||
minute => $minute,
|
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.
|
|
@ -14,10 +14,12 @@ describe 'nova::cron::archive_deleted_rows' do
|
||||||
:weekday => '*',
|
:weekday => '*',
|
||||||
:max_rows => '100',
|
:max_rows => '100',
|
||||||
:user => 'nova',
|
:user => 'nova',
|
||||||
|
:until_complete => false,
|
||||||
:destination => '/var/log/nova/nova-rowsflush.log' }
|
:destination => '/var/log/nova/nova-rowsflush.log' }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures a cron' do
|
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(
|
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",
|
: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',
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
|
@ -30,5 +32,27 @@ describe 'nova::cron::archive_deleted_rows' do
|
||||||
:require => 'Anchor[nova::dbsync::end]',
|
:require => 'Anchor[nova::dbsync::end]',
|
||||||
)
|
)
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue