From 744f4bbcf5bfa8d09993c6e598b10c4190c10467 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Sat, 4 Apr 2015 13:40:45 +0200 Subject: [PATCH] Create a sync_db boolean for Heat. Other components offer the option to decide whether or not to run the db sync command. Heat was missing this feature. This commit add this feature for Heat. Change-Id: I06b669123fe08e02c66ee34dab78a943ff5de90c --- manifests/api.pp | 2 +- manifests/api_cfn.pp | 2 +- manifests/api_cloudwatch.pp | 2 +- manifests/engine.pp | 5 +++-- manifests/init.pp | 22 +++++++++++++++------- spec/classes/heat_api_cfn_spec.rb | 11 +++++++++++ spec/classes/heat_api_cloudwatch_spec.rb | 11 +++++++++++ spec/classes/heat_api_spec.rb | 10 ++++++++++ spec/classes/heat_engine_spec.rb | 15 +++++++++++++++ 9 files changed, 68 insertions(+), 12 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index b90a4e0c..ee1c2d67 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -95,7 +95,7 @@ class heat::api ( hasrestart => true, require => [Package['heat-common'], Package['heat-api']], - subscribe => Exec['heat-dbsync'], + subscribe => $::heat::subscribe_sync_db, } heat_config { diff --git a/manifests/api_cfn.pp b/manifests/api_cfn.pp index 9738eb41..ab7603f8 100644 --- a/manifests/api_cfn.pp +++ b/manifests/api_cfn.pp @@ -98,7 +98,7 @@ class heat::api_cfn ( enable => $enabled, hasstatus => true, hasrestart => true, - subscribe => Exec['heat-dbsync'], + subscribe => $::heat::subscribe_sync_db, } heat_config { diff --git a/manifests/api_cloudwatch.pp b/manifests/api_cloudwatch.pp index 8f4a64cd..034bd3af 100644 --- a/manifests/api_cloudwatch.pp +++ b/manifests/api_cloudwatch.pp @@ -98,7 +98,7 @@ class heat::api_cloudwatch ( enable => $enabled, hasstatus => true, hasrestart => true, - subscribe => Exec['heat-dbsync'], + subscribe => $::heat::subscribe_sync_db, } heat_config { diff --git a/manifests/engine.pp b/manifests/engine.pp index 6a62cec0..0dc9dcb2 100644 --- a/manifests/engine.pp +++ b/manifests/engine.pp @@ -67,6 +67,7 @@ class heat::engine ( $configure_delegated_roles = true, #DEPRECATED ) { + include ::heat include ::heat::params Heat_config<||> ~> Service['heat-engine'] @@ -77,7 +78,7 @@ class heat::engine ( ensure => installed, name => $::heat::params::engine_package_name, tag => 'openstack', - notify => Exec['heat-dbsync'], + notify => $::heat::subscribe_sync_db, } if $manage_service { @@ -104,7 +105,7 @@ class heat::engine ( require => [ File['/etc/heat/heat.conf'], Package['heat-common'], Package['heat-engine']], - subscribe => Exec['heat-dbsync'], + subscribe => $::heat::subscribe_sync_db, } heat_config { diff --git a/manifests/init.pp b/manifests/init.pp index 0d56db64..c20b3c8c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -164,6 +164,10 @@ # (Optional) Enable the stack-abandon feature. # Defaults to undef # +# [*sync_db*] +# (Optional) Run db sync on nodes after connection setting has been set. +# Defaults to true +# # === Deprecated Parameters # # [*mysql_module*] @@ -229,6 +233,7 @@ class heat( $region_name = undef, $enable_stack_adopt = undef, $enable_stack_abandon = undef, + $sync_db = true, # Deprecated parameters $mysql_module = undef, $sql_connection = undef, @@ -506,14 +511,17 @@ class heat( value => $database_idle_timeout; } - Heat_config['database/connection'] ~> Exec['heat-dbsync'] + if $sync_db { + $subscribe_sync_db = Exec['heat-dbsync'] + Heat_config['database/connection'] ~> Exec['heat-dbsync'] - exec { 'heat-dbsync': - command => $::heat::params::dbsync_command, - path => '/usr/bin', - user => 'heat', - refreshonly => true, - logoutput => on_failure, + exec { 'heat-dbsync': + command => $::heat::params::dbsync_command, + path => '/usr/bin', + user => 'heat', + refreshonly => true, + logoutput => on_failure, + } } } diff --git a/spec/classes/heat_api_cfn_spec.rb b/spec/classes/heat_api_cfn_spec.rb index 20ffeb31..6af343a9 100644 --- a/spec/classes/heat_api_cfn_spec.rb +++ b/spec/classes/heat_api_cfn_spec.rb @@ -100,6 +100,17 @@ describe 'heat::api_cfn' do is_expected.to contain_service('heat-api-cfn').that_subscribes_to('Exec[heat-dbsync]') end end + + context 'with $sync_db set to false in ::heat' do + let :pre_condition do + "class {'heat': sync_db => false}" + end + + it 'configures heat-api-cfn service to not subscribe to the dbsync resource' do + is_expected.to contain_service('heat-api-cfn').that_subscribes_to(nil) + end + end + end diff --git a/spec/classes/heat_api_cloudwatch_spec.rb b/spec/classes/heat_api_cloudwatch_spec.rb index a61caa6e..7077d87c 100644 --- a/spec/classes/heat_api_cloudwatch_spec.rb +++ b/spec/classes/heat_api_cloudwatch_spec.rb @@ -100,6 +100,17 @@ describe 'heat::api_cloudwatch' do is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to('Exec[heat-dbsync]') end end + + context 'with $sync_db set to false in ::heat' do + let :pre_condition do + "class {'heat': sync_db => false}" + end + + it 'configures heat-api-cloudwatch service to not subscribe to the dbsync resource' do + is_expected.to contain_service('heat-api-cloudwatch').that_subscribes_to(nil) + end + end + end context 'on Debian platforms' do diff --git a/spec/classes/heat_api_spec.rb b/spec/classes/heat_api_spec.rb index 32ccb755..91589ff1 100644 --- a/spec/classes/heat_api_spec.rb +++ b/spec/classes/heat_api_spec.rb @@ -103,6 +103,16 @@ describe 'heat::api' do is_expected.to contain_service('heat-api').that_subscribes_to('Exec[heat-dbsync]') end end + + context 'with $sync_db set to false in ::heat' do + let :pre_condition do + "class {'heat': sync_db => false}" + end + + it 'configures heat-api service to not subscribe to the dbsync resource' do + is_expected.to contain_service('heat-api').that_subscribes_to(nil) + end + end end context 'on Debian platforms' do diff --git a/spec/classes/heat_engine_spec.rb b/spec/classes/heat_engine_spec.rb index 495d088d..fad0c816 100644 --- a/spec/classes/heat_engine_spec.rb +++ b/spec/classes/heat_engine_spec.rb @@ -99,6 +99,21 @@ describe 'heat::engine' do :subscribe => 'Exec[heat-dbsync]' ) } end + context 'with $sync_db set to false in ::heat' do + let :pre_condition do + "class {'heat': sync_db => false}" + end + + it 'configures heat-engine service to not subscribe to the dbsync resource' do + is_expected.to contain_service('heat-engine').that_subscribes_to(nil) + end + + it 'configures the heat-engine package to not be notified by the dbsync resource ' do + is_expected.to contain_package('heat-engine').with( + :notify => nil, + ) + end + end end context 'on Debian platforms' do