From bb08feae87642519524f2fa233e88cb65ee7bae8 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Mon, 2 Dec 2019 16:25:31 +0100 Subject: [PATCH] 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 --- manifests/cron/archive_deleted_rows.pp | 15 +++++++- ...l-cells-archive-cron-065604f9953191ea.yaml | 6 +++ spec/acceptance/nova_wsgi_apache_spec.rb | 2 +- .../nova_cron_archive_deleted_rows_spec.rb | 37 +++++++++++++++---- 4 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/add-all-cells-archive-cron-065604f9953191ea.yaml diff --git a/manifests/cron/archive_deleted_rows.pp b/manifests/cron/archive_deleted_rows.pp index 7ecb2853e..9aea87be9 100644 --- a/manifests/cron/archive_deleted_rows.pp +++ b/manifests/cron/archive_deleted_rows.pp @@ -67,6 +67,10 @@ # all cron jobs at the same time on all hosts this job is configured. # Defaults to 0. # +# [*all_cells*] +# (optional) Adds --all-cells to the archive command +# Defaults to false. +# class nova::cron::archive_deleted_rows ( $minute = 1, @@ -80,6 +84,7 @@ class nova::cron::archive_deleted_rows ( $until_complete = false, $purge = false, $maxdelay = 0, + $all_cells = false, ) { include ::nova::deps @@ -99,6 +104,13 @@ class nova::cron::archive_deleted_rows ( $purge_real = '' } + if $all_cells { + $all_cells_real = '--all-cells' + } + else { + $all_cells_real = '' + } + if $maxdelay == 0 { $sleep = '' } else { @@ -108,7 +120,8 @@ class nova::cron::archive_deleted_rows ( $cron_cmd = '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', user => pick($user, $::nova::params::nova_user), minute => $minute, diff --git a/releasenotes/notes/add-all-cells-archive-cron-065604f9953191ea.yaml b/releasenotes/notes/add-all-cells-archive-cron-065604f9953191ea.yaml new file mode 100644 index 000000000..56b8c0b50 --- /dev/null +++ b/releasenotes/notes/add-all-cells-archive-cron-065604f9953191ea.yaml @@ -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. diff --git a/spec/acceptance/nova_wsgi_apache_spec.rb b/spec/acceptance/nova_wsgi_apache_spec.rb index abff24dc4..21ceccf29 100644 --- a/spec/acceptance/nova_wsgi_apache_spec.rb +++ b/spec/acceptance/nova_wsgi_apache_spec.rb @@ -58,7 +58,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 diff --git a/spec/classes/nova_cron_archive_deleted_rows_spec.rb b/spec/classes/nova_cron_archive_deleted_rows_spec.rb index d8ee8d5d6..91c509d65 100644 --- a/spec/classes/nova_cron_archive_deleted_rows_spec.rb +++ b/spec/classes/nova_cron_archive_deleted_rows_spec.rb @@ -13,14 +13,15 @@ describe 'nova::cron::archive_deleted_rows' do :max_rows => '100', :user => 'nova', :until_complete => false, + :all_cells => false, :maxdelay => 0, :destination => '/var/log/nova/nova-rowsflush.log' } end - context 'until_complete is false' do - it 'configures a cron without until_complete' do + context 'until_complete and all_cells is false' do + it 'configures a cron without until_complete and 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]} >>#{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', :user => params[:user], :minute => params[:minute], @@ -42,7 +43,29 @@ describe 'nova::cron::archive_deleted_rows' do 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", + :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', :user => params[:user], :minute => params[:minute], @@ -64,7 +87,7 @@ describe 'nova::cron::archive_deleted_rows' do it 'configures a cron with purge' do 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', :user => params[:user], :minute => params[:minute], @@ -87,7 +110,7 @@ describe 'nova::cron::archive_deleted_rows' do it 'configures a cron with all purge params' do 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', :user => params[:user], :minute => params[:minute], @@ -109,7 +132,7 @@ describe 'nova::cron::archive_deleted_rows' do it 'configures a cron with maxdelay' do 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', :user => params[:user], :minute => params[:minute],