Fix up pacemaker_status test in yum_update.sh
authorMichele Baldessari <michele@acksyn.org>
Thu, 4 May 2017 09:46:45 +0000 (11:46 +0200)
committerMichele Baldessari <michele@acksyn.org>
Mon, 8 May 2017 08:40:14 +0000 (10:40 +0200)
commit43b33c7ed8ae2b02dc552767eaa7eb1dec4fb2e1
treedaea4c1a9548262512ee739af70ccd8366d6c30f
parentc224a4c7c9441e9ed0481bdeebcf65fee5d998bc
Fix up pacemaker_status test in yum_update.sh

In change I2aae4e2fdfec526c835f8967b54e1db3757bca17 we did the
following:
-pacemaker_status=$(systemctl is-active pacemaker || :)
+pacemaker_status=""
+if hiera -c /etc/puppet/hiera.yaml service_names | grep -q pacemaker;
then
+ pacemaker_status=$(systemctl is-active pacemaker)
+fi

we did that so due to LP#1668266: we did not want systemctl is-active to
fail on non pacemaker nodes. The problem with the above hiera check is
that it will match on pacemaker_remote nodes as well.

We cannot piggyback the pacemaker_enabled hiera key because that is true
on all nodes. So let's make the test check only for pacemaker service
without matching pacemaker remote. Tested with:
1) Test on a controller node with pacemaker service enabled
[root@overcloud-controller-0 ~]# hiera -c /etc/puppet/hiera.yaml -a service_names |grep '\bpacemaker\b'
"pacemaker",
[root@overcloud-controller-0 ~]# echo $?
0

2) Test on a compute node without pacemaker:
[root@overcloud-novacompute-0 puppet]# hiera -c /etc/puppet/hiera.yaml service_names |grep '\bpacemaker\b'
[root@overcloud-novacompute-0 puppet]# echo $?
1

3) Test on a node with pacemaker_remote in the service_names key:
[root@overcloud-novacompute-0 puppet]# hiera -c /etc/puppet/hiera.yaml service_names |grep '\bpacemaker\b'
[root@overcloud-novacompute-0 puppet]# echo $?
1

[root@overcloud-novacompute-0 puppet]# hiera -c /etc/puppet/hiera.yaml service_names |grep '\bpacemaker_remote\b'
 "pacemaker_remote"]
[root@overcloud-novacompute-0 puppet]# echo $?
0

NB: cherry-pick was not 100% clean due to unrelated lines being cleaned
up in master.

Change-Id: I54c5756ba6dea791aef89a79bc0b538ba02ae48a
Closes-Bug: #1688214
(cherry picked from commit 2244290424ffa7781fb5b64688908c218cd10ecd)
extraconfig/tasks/yum_update.sh