Make heat task idempotent

This change updates the heat task to be idempotent. In order to do this,
we have changed the wait_for_heat_config exec to be refresh only and is
now only triggered if configuration changes are done. Additionally this
change cleans up the pacemaker integration for heat and moves it into
the cluster module. With the addition to the cluster module, unit tests
have been added to the new cluster::heat_engine class.

The resources that were always being executed prior to this change:
 - Cs_resource[p_heat-engine]
 - Exec[wait_for_heat_config]

Change-Id: Ie0f7137206f2733259bff7b0c2c86fb1634add76
Related-Blueprint: granular-task-idempotency
This commit is contained in:
Alex Schultz 2016-02-05 14:26:26 -07:00
parent 3c9cefd1e0
commit 569ebdb59d
8 changed files with 162 additions and 46 deletions

View File

@ -7,3 +7,6 @@ fixtures:
pacemaker: "#{source_dir}/../pacemaker"
pacemaker_wrappers: "#{source_dir}/../pacemaker_wrappers"
ntp: "#{source_dir}/../ntp"
heat: "#{source_dir}/../heat"
openstacklib: "#{source_dir}/../openstacklib"
inifile: "#{source_dir}/../inifile"

View File

@ -0,0 +1,53 @@
#
# Configure heat-engine in pacemaker/corosync
#
# == Parameters
#
# None.
#
# === Notes
#
# This class requires that ::heat::engine be included in the catalog prior to
# the inclusion of this class.
#
class cluster::heat_engine {
include ::heat::engine
include ::heat::params
$primitive_type = 'heat-engine'
# migration-threshold is number of tries to
# start resource on each controller node
$metadata = {
'resource-stickiness' => '1',
'migration-threshold' => '3'
}
$operations = {
'monitor' => {
'interval' => '20',
'timeout' => '30',
},
'start' => {
'interval' => '0',
'timeout' => '60',
},
'stop' => {
'interval' => '0',
'timeout' => '60',
},
}
$ms_metadata = {
'interleave' => true,
}
pacemaker_wrappers::service { $::heat::params::engine_service_name :
primitive_type => $primitive_type,
metadata => $metadata,
complex_type => 'clone',
ms_metadata => $ms_metadata,
operations => $operations,
}
}

View File

@ -0,0 +1,84 @@
require 'spec_helper'
describe 'cluster::heat_engine' do
let(:pre_condition) do
"class { '::heat::engine': auth_encryption_key => 'deadb33fdeadb33f' }"
end
shared_examples_for 'cluster::heat_engine configuration' do
context 'with valid params' do
let :params do
{ }
end
it {
should contain_class('cluster::heat_engine')
}
it 'configures a heat engine pacemaker service' do
should contain_pacemaker_wrappers__service(platform_params[:engine_service_name]).with(
:primitive_type => 'heat-engine',
:metadata => {
'resource-stickiness' => '1',
'migration-threshold' => '3'
},
:complex_type => 'clone',
:ms_metadata => {
'interleave' => true
},
:operations => {
'monitor' => {
'interval' => '20',
'timeout' => '30'
},
'start' => {
'interval' => '0',
'timeout' => '60'
},
'stop' => {
'interval' => '0',
'timeout' => '60'
},
}
)
end
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:hostname => 'hostname.example.com',
:os_service_default => '<SERVICE DEFAULT>'
}
end
let :platform_params do
{
:engine_service_name => 'heat-engine'
}
end
it_configures 'cluster::heat_engine configuration'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:hostname => 'hostname.example.com',
:os_service_default => '<SERVICE DEFAULT>'
}
end
let :platform_params do
{
:engine_service_name => 'openstack-heat-engine'
}
end
it_configures 'cluster::heat_engine configuration'
end
end

View File

@ -1,38 +0,0 @@
class heat_ha::engine inherits heat::engine {
include heat::params
$primitive_type = 'heat-engine'
# migration-threshold is number of tries to
# start resource on each controller node
$metadata = {
'resource-stickiness' => '1',
'migration-threshold' => '3'
}
$operations = {
'monitor' => {
'interval' => '20',
'timeout' => '30',
},
'start' => {
'timeout' => '60',
},
'stop' => {
'timeout' => '60',
},
}
$ms_metadata = {
'interleave' => true,
}
pacemaker_wrappers::service { $::heat::params::engine_service_name :
primitive_type => $primitive_type,
metadata => $metadata,
complex_type => 'clone',
ms_metadata => $ms_metadata,
operations => $operations,
}
}

View File

@ -123,7 +123,7 @@ class { 'openstack::heat' :
if hiera('heat_ha_engine', true){
if ($deployment_mode == 'ha') or ($deployment_mode == 'ha_compact') {
include ::heat_ha::engine
include ::cluster::heat_engine
}
}
@ -190,14 +190,14 @@ Class['heat'] ->
######################
exec { 'wait_for_heat_config' :
command => 'sync && sleep 3',
provider => 'shell',
command => 'sync && sleep 3',
provider => 'shell',
refreshonly => true,
}
Heat_config <||> -> Exec['wait_for_heat_config'] -> Service['heat-api']
Heat_config <||> -> Exec['wait_for_heat_config'] -> Service['heat-api-cfn']
Heat_config <||> -> Exec['wait_for_heat_config'] -> Service['heat-api-cloudwatch']
Heat_config <||> -> Exec['wait_for_heat_config'] -> Service['heat-engine']
Heat_config <||> ~>
Exec['wait_for_heat_config'] ->
Service <| tag == 'heat-service' |>
######################

View File

@ -18,6 +18,10 @@ describe manifest do
Noop.puppet_function 'get_network_role_property', 'mgmt/memcache', 'ipaddr'
end
let(:heat_ha_engine) do
Noop.hiera 'heat_ha_engine', true
end
admin_auth_protocol = 'http'
admin_auth_address = Noop.hiera('service_endpoint')
if Noop.hiera_structure('use_ssl', false)
@ -155,6 +159,14 @@ describe manifest do
)
}
it 'should configure heat ha engine' do
if heat_ha_engine
should contain_class('cluster::heat_engine')
else
should_not contain_class('cluster::heat_engine')
end
end
end # end of shared_examples
test_ubuntu_and_centos manifest

View File

@ -1,3 +1,6 @@
# List of modules with disabled 'rake lint' check.
# Such modules will be checked with 'puppet-lint' command.
# No need to include here modules defined in the fuel-library Puppetfile.
# TODO(aschultz): this is needed to get while it's being removed, should be
# removed in a follow on commit
heat_ha

View File

@ -1,7 +1,6 @@
# List of modules with disabled 'rake spec' check.
# No need to include here modules defined in the fuel-library Puppetfile.
docker
heat_ha
mellanox_openstack
mysql
pacemaker