From 81d4dfa7e0c5d4fcc1cd9fae19b860184c6e351f Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 2 Aug 2018 08:36:52 +0200 Subject: [PATCH] Force cinder properties to be set on ly on nodes with pcmk on it When using the BlockStorage role there is one cinder volume per node and those are not managed by pcmk. So when we force the property for all nodes that have cinder_volume we will fail because pcmk is not running on those nodes. Let's not set properties for nodes that are not running pacemaker. While we're at it let's remove *_nodes_count which are not used anyway. Closes-Bug: #1786412 Change-Id: I42e9f3244bad60b5df2dfa940f132f72c606620e --- manifests/profile/pacemaker/cinder/backup_bundle.pp | 6 +++--- manifests/profile/pacemaker/cinder/volume_bundle.pp | 6 +++--- .../tripleo_profile_pacemaker_cinder_backup_bundle_spec.rb | 6 +++--- .../tripleo_profile_pacemaker_cinder_volume_bundle_spec.rb | 6 +++--- spec/fixtures/hieradata/default.yaml | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/profile/pacemaker/cinder/backup_bundle.pp b/manifests/profile/pacemaker/cinder/backup_bundle.pp index 7746d4af7..313301f58 100644 --- a/manifests/profile/pacemaker/cinder/backup_bundle.pp +++ b/manifests/profile/pacemaker/cinder/backup_bundle.pp @@ -62,7 +62,9 @@ class tripleo::profile::pacemaker::cinder::backup_bundle ( if $step >= 2 and $pacemaker_master { $cinder_backup_short_node_names = hiera('cinder_backup_short_node_names') - $cinder_backup_short_node_names.each |String $node_name| { + $pacemaker_short_node_names = hiera('pacemaker_short_node_names') + $pcmk_cinder_backup_nodes = intersection($cinder_backup_short_node_names, $pacemaker_short_node_names) + $pcmk_cinder_backup_nodes.each |String $node_name| { pacemaker::property { "cinder-backup-role-${node_name}": property => 'cinder-backup-role', value => true, @@ -75,8 +77,6 @@ class tripleo::profile::pacemaker::cinder::backup_bundle ( if $step >= 5 { if $pacemaker_master { - $cinder_backup_nodes_count = count(hiera('cinder_backup_short_node_names', [])) - $docker_vol_arr = delete(any2array($docker_volumes), '').flatten() unless empty($docker_vol_arr) { diff --git a/manifests/profile/pacemaker/cinder/volume_bundle.pp b/manifests/profile/pacemaker/cinder/volume_bundle.pp index ae70a42e0..cce7a9ab7 100644 --- a/manifests/profile/pacemaker/cinder/volume_bundle.pp +++ b/manifests/profile/pacemaker/cinder/volume_bundle.pp @@ -62,7 +62,9 @@ class tripleo::profile::pacemaker::cinder::volume_bundle ( if $step >= 2 and $pacemaker_master { $cinder_volume_short_node_names = hiera('cinder_volume_short_node_names') - $cinder_volume_short_node_names.each |String $node_name| { + $pacemaker_short_node_names = hiera('pacemaker_short_node_names') + $pcmk_cinder_volume_nodes = intersection($cinder_volume_short_node_names, $pacemaker_short_node_names) + $pcmk_cinder_volume_nodes.each |String $node_name| { pacemaker::property { "cinder-volume-role-${node_name}": property => 'cinder-volume-role', value => true, @@ -75,8 +77,6 @@ class tripleo::profile::pacemaker::cinder::volume_bundle ( if $step >= 5 { if $pacemaker_master { - $cinder_volume_nodes_count = count(hiera('cinder_volume_short_node_names', [])) - $docker_vol_arr = delete(any2array($docker_volumes), '').flatten() unless empty($docker_vol_arr) { diff --git a/spec/classes/tripleo_profile_pacemaker_cinder_backup_bundle_spec.rb b/spec/classes/tripleo_profile_pacemaker_cinder_backup_bundle_spec.rb index 3a60ef97f..de3208e25 100644 --- a/spec/classes/tripleo_profile_pacemaker_cinder_backup_bundle_spec.rb +++ b/spec/classes/tripleo_profile_pacemaker_cinder_backup_bundle_spec.rb @@ -36,8 +36,8 @@ describe 'tripleo::profile::pacemaker::cinder::backup_bundle' do } } it 'should create pacemaker properties' do - is_expected.to contain_pacemaker__property('cinder-backup-role-c-bak-1') - is_expected.to contain_pacemaker__property('cinder-backup-role-c-bak-2') + is_expected.to contain_pacemaker__property('cinder-backup-role-node.example.com') + is_expected.to_not contain_pacemaker__property('cinder-backup-role-c-bak-2') end end @@ -48,7 +48,7 @@ describe 'tripleo::profile::pacemaker::cinder::backup_bundle' do } } it 'should not create pacemaker properties' do - is_expected.to_not contain_pacemaker__property('cinder-backup-role-c-bak-1') + is_expected.to_not contain_pacemaker__property('cinder-backup-role-node.example.com') is_expected.to_not contain_pacemaker__property('cinder-backup-role-c-bak-2') end end diff --git a/spec/classes/tripleo_profile_pacemaker_cinder_volume_bundle_spec.rb b/spec/classes/tripleo_profile_pacemaker_cinder_volume_bundle_spec.rb index a2b9c48c7..87ac1305b 100644 --- a/spec/classes/tripleo_profile_pacemaker_cinder_volume_bundle_spec.rb +++ b/spec/classes/tripleo_profile_pacemaker_cinder_volume_bundle_spec.rb @@ -41,8 +41,8 @@ describe 'tripleo::profile::pacemaker::cinder::volume_bundle' do } } it 'should create pacemaker properties' do - is_expected.to contain_pacemaker__property('cinder-volume-role-c-vol-1') - is_expected.to contain_pacemaker__property('cinder-volume-role-c-vol-2') + is_expected.to contain_pacemaker__property('cinder-volume-role-node.example.com') + is_expected.to_not contain_pacemaker__property('cinder-volume-role-c-vol-2') end end @@ -53,7 +53,7 @@ describe 'tripleo::profile::pacemaker::cinder::volume_bundle' do } } it 'should not create pacemaker properties' do - is_expected.to_not contain_pacemaker__property('cinder-volume-role-c-vol-1') + is_expected.to_not contain_pacemaker__property('cinder-volume-role-node.example.com') is_expected.to_not contain_pacemaker__property('cinder-volume-role-c-vol-2') end end diff --git a/spec/fixtures/hieradata/default.yaml b/spec/fixtures/hieradata/default.yaml index 94a7eb225..ab64760f7 100644 --- a/spec/fixtures/hieradata/default.yaml +++ b/spec/fixtures/hieradata/default.yaml @@ -28,11 +28,11 @@ ceph::profile::params::rgw_keystone_admin_password: 'keystone_admin_password' # cinder related items cinder_backup_short_bootstrap_node_name: 'node.example.com' cinder_backup_short_node_names: - - 'c-bak-1' + - 'node.example.com' - 'c-bak-2' cinder_volume_short_bootstrap_node_name: 'node.example.com' cinder_volume_short_node_names: - - 'c-vol-1' + - 'node.example.com' - 'c-vol-2' cinder::backup::nfs::backup_share: '/mnt/backup' cinder::rabbit_password: 'password'