From 67139207a9e8d3752280c3dcc78c264a3ff1eaa7 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 27 Dec 2021 22:24:14 +0900 Subject: [PATCH] Enable DB purge cron job after database is initialized The DB purge operation expects the target database is already initialized. This change ensures db sync is completed before cron job is enabled. Closes-Bug: #1955829 Change-Id: I742ea262bde8b9412627a475c53b27d25e132787 --- manifests/cron/purge_deleted.pp | 5 ++--- spec/classes/heat_cron_purge_deleted_spec.rb | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifests/cron/purge_deleted.pp b/manifests/cron/purge_deleted.pp index e86e5df7..210cc093 100644 --- a/manifests/cron/purge_deleted.pp +++ b/manifests/cron/purge_deleted.pp @@ -79,8 +79,7 @@ class heat::cron::purge_deleted ( hour => $hour, monthday => $monthday, month => $month, - weekday => $weekday + weekday => $weekday, + require => Anchor['heat::dbsync::end'] } - - Package<| tag == 'heat-package' |> -> Cron['heat-manage purge_deleted'] } diff --git a/spec/classes/heat_cron_purge_deleted_spec.rb b/spec/classes/heat_cron_purge_deleted_spec.rb index 9cca71da..f228e1cf 100644 --- a/spec/classes/heat_cron_purge_deleted_spec.rb +++ b/spec/classes/heat_cron_purge_deleted_spec.rb @@ -35,9 +35,9 @@ describe 'heat::cron::purge_deleted' do :hour => params[:hour], :monthday => params[:monthday], :month => params[:month], - :weekday => params[:weekday] + :weekday => params[:weekday], + :require => 'Anchor[heat::dbsync::end]' ) - is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]') end end @@ -58,9 +58,9 @@ describe 'heat::cron::purge_deleted' do :hour => params[:hour], :monthday => params[:monthday], :month => params[:month], - :weekday => params[:weekday] + :weekday => params[:weekday], + :require => 'Anchor[heat::dbsync::end]' ) - is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]') end end @@ -71,7 +71,7 @@ describe 'heat::cron::purge_deleted' do ) end - it 'configures a cron with delay' do + it 'disables the cron job' do is_expected.to contain_cron('heat-manage purge_deleted').with( :ensure => params[:ensure], :command => "heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1", @@ -81,9 +81,9 @@ describe 'heat::cron::purge_deleted' do :hour => params[:hour], :monthday => params[:monthday], :month => params[:month], - :weekday => params[:weekday] + :weekday => params[:weekday], + :require => 'Anchor[heat::dbsync::end]' ) - is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]') end end