Adds --all-cells to the archive command

Adds --all-cells to the archive command based on an empty_table
boolean flag. If true, it will run in archive command on all
configured cells.

Depends-On: https://review.opendev.org/697012

Change-Id: Iaa47181318eb8b9251d47fd381784791f4967a4e
This commit is contained in:
Martin Schuppert 2019-12-02 16:25:31 +01:00
parent 715043f3e1
commit bb08feae87
4 changed files with 51 additions and 9 deletions

View File

@ -67,6 +67,10 @@
# all cron jobs at the same time on all hosts this job is configured. # all cron jobs at the same time on all hosts this job is configured.
# Defaults to 0. # Defaults to 0.
# #
# [*all_cells*]
# (optional) Adds --all-cells to the archive command
# Defaults to false.
#
class nova::cron::archive_deleted_rows ( class nova::cron::archive_deleted_rows (
$minute = 1, $minute = 1,
@ -80,6 +84,7 @@ class nova::cron::archive_deleted_rows (
$until_complete = false, $until_complete = false,
$purge = false, $purge = false,
$maxdelay = 0, $maxdelay = 0,
$all_cells = false,
) { ) {
include ::nova::deps include ::nova::deps
@ -99,6 +104,13 @@ class nova::cron::archive_deleted_rows (
$purge_real = '' $purge_real = ''
} }
if $all_cells {
$all_cells_real = '--all-cells'
}
else {
$all_cells_real = ''
}
if $maxdelay == 0 { if $maxdelay == 0 {
$sleep = '' $sleep = ''
} else { } else {
@ -108,7 +120,8 @@ class nova::cron::archive_deleted_rows (
$cron_cmd = 'nova-manage db archive_deleted_rows' $cron_cmd = 'nova-manage db archive_deleted_rows'
cron { 'nova-manage db archive_deleted_rows': cron { 'nova-manage db archive_deleted_rows':
command => "${sleep}${cron_cmd} ${purge_real} --max_rows ${max_rows} ${until_complete_real} >>${destination} 2>&1", command => "${sleep}${cron_cmd} ${purge_real} --max_rows ${max_rows} ${until_complete_real} \
${all_cells_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 => pick($user, $::nova::params::nova_user), user => pick($user, $::nova::params::nova_user),
minute => $minute, minute => $minute,

View File

@ -0,0 +1,6 @@
---
features:
- Adds --all-cells to the archive command
based on an empty_table boolean flag.
If true, it will run in archive command
on all configured cells.

View File

@ -58,7 +58,7 @@ describe 'basic nova' do
end end
describe cron do 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 end
describe 'nova aggregate' do describe 'nova aggregate' do

View File

@ -13,14 +13,15 @@ describe 'nova::cron::archive_deleted_rows' do
:max_rows => '100', :max_rows => '100',
:user => 'nova', :user => 'nova',
:until_complete => false, :until_complete => false,
:all_cells => false,
:maxdelay => 0, :maxdelay => 0,
:destination => '/var/log/nova/nova-rowsflush.log' } :destination => '/var/log/nova/nova-rowsflush.log' }
end end
context 'until_complete is false' do context 'until_complete and all_cells is false' do
it 'configures a cron without until_complete' do it 'configures a cron without until_complete and all_cells' 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',
:user => params[:user], :user => params[:user],
:minute => params[:minute], :minute => params[:minute],
@ -42,7 +43,29 @@ describe 'nova::cron::archive_deleted_rows' do
it 'configures a cron with until_complete' do it 'configures a cron with 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]} --until-complete >>#{params[:destination]} 2>&1", :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
context 'all_cells is true' do
before :each do
params.merge!(
:all_cells => true,
)
end
it 'configures a cron with all_cells' 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]} --all-cells >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => params[:user], :user => params[:user],
:minute => params[:minute], :minute => params[:minute],
@ -64,7 +87,7 @@ describe 'nova::cron::archive_deleted_rows' do
it 'configures a cron with purge' do it 'configures a cron with purge' 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 --purge --max_rows #{params[:max_rows]} >>#{params[:destination]} 2>&1", :command => "nova-manage db archive_deleted_rows --purge --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',
:user => params[:user], :user => params[:user],
:minute => params[:minute], :minute => params[:minute],
@ -87,7 +110,7 @@ describe 'nova::cron::archive_deleted_rows' do
it 'configures a cron with all purge params' do it 'configures a cron with all purge params' 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 --purge --max_rows #{params[:max_rows]} --until-complete >>#{params[:destination]} 2>&1", :command => "nova-manage db archive_deleted_rows --purge --max_rows #{params[:max_rows]} --until-complete >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => params[:user], :user => params[:user],
:minute => params[:minute], :minute => params[:minute],
@ -109,7 +132,7 @@ describe 'nova::cron::archive_deleted_rows' do
it 'configures a cron with maxdelay' do it 'configures a cron with maxdelay' 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 => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; nova-manage db archive_deleted_rows --max_rows #{params[:max_rows]} >>#{params[:destination]} 2>&1", :command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; 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',
:user => params[:user], :user => params[:user],
:minute => params[:minute], :minute => params[:minute],