|
|
e3c68b |
From 2d5e678f8331d4d99ee4dff6e166cbf01c83ab36 Mon Sep 17 00:00:00 2001
|
|
|
e3c68b |
From: "Kaleb S. KEITHLEY" <kkeithle@redhat.com>
|
|
|
e3c68b |
Date: Wed, 12 Feb 2020 12:47:57 -0500
|
|
|
e3c68b |
Subject: [PATCH 357/357] ganesha-ha: updates for pcs-0.10.x (i.e. in Fedora-29
|
|
|
e3c68b |
and RHEL-8)
|
|
|
e3c68b |
|
|
|
e3c68b |
pcs-0.10 has introduced changes options to pcs commands
|
|
|
e3c68b |
|
|
|
e3c68b |
pcs-0.10.x is in Fedora-29 and later and RHEL-8.
|
|
|
e3c68b |
|
|
|
e3c68b |
Also some minor cleanup. Namely use bash built-in [[...]] in a few
|
|
|
e3c68b |
more places instead of test(1), i.e. [...], and use correct "==" for
|
|
|
e3c68b |
comparison.
|
|
|
e3c68b |
|
|
|
e3c68b |
master: https://review.gluster.org/24115
|
|
|
e3c68b |
|
|
|
e3c68b |
Change-Id: I3fb2fcd71406964c77fdc4f18580ca133f365fd6
|
|
|
e3c68b |
BUG: 1802727
|
|
|
e3c68b |
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
|
|
|
e3c68b |
Reviewed-on: https://code.engineering.redhat.com/gerrit/194467
|
|
|
e3c68b |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
e3c68b |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
e3c68b |
---
|
|
|
e3c68b |
extras/ganesha/scripts/ganesha-ha.sh | 84 ++++++++++++++++++++++++------------
|
|
|
e3c68b |
1 file changed, 56 insertions(+), 28 deletions(-)
|
|
|
e3c68b |
|
|
|
e3c68b |
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
e3c68b |
index 32af1ca..0b0050a 100644
|
|
|
e3c68b |
--- a/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
e3c68b |
+++ b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
e3c68b |
@@ -28,7 +28,12 @@ HA_VOL_MNT="/var/run/gluster/shared_storage"
|
|
|
e3c68b |
HA_CONFDIR=$HA_VOL_MNT"/nfs-ganesha"
|
|
|
e3c68b |
SERVICE_MAN="DISTRO_NOT_FOUND"
|
|
|
e3c68b |
|
|
|
e3c68b |
-RHEL6_PCS_CNAME_OPTION="--name"
|
|
|
e3c68b |
+# rhel, fedora id, version
|
|
|
e3c68b |
+ID=""
|
|
|
e3c68b |
+VERSION_ID=""
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+PCS9OR10_PCS_CNAME_OPTION=""
|
|
|
e3c68b |
+PCS9OR10_PCS_CLONE_OPTION="clone"
|
|
|
e3c68b |
SECRET_PEM="/var/lib/glusterd/nfs/secret.pem"
|
|
|
e3c68b |
|
|
|
e3c68b |
# UNBLOCK RA uses shared_storage which may become unavailable
|
|
|
e3c68b |
@@ -101,9 +106,9 @@ determine_service_manager () {
|
|
|
e3c68b |
then
|
|
|
e3c68b |
SERVICE_MAN="/sbin/service"
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
- if [ "${SERVICE_MAN}" == "DISTRO_NOT_FOUND" ]
|
|
|
e3c68b |
+ if [[ "${SERVICE_MAN}X" == "DISTRO_NOT_FOUNDX" ]]
|
|
|
e3c68b |
then
|
|
|
e3c68b |
- echo "Service manager not recognized, exiting"
|
|
|
e3c68b |
+ logger "Service manager not recognized, exiting"
|
|
|
e3c68b |
exit 1
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
}
|
|
|
e3c68b |
@@ -114,7 +119,7 @@ manage_service ()
|
|
|
e3c68b |
local new_node=${2}
|
|
|
e3c68b |
local option=
|
|
|
e3c68b |
|
|
|
e3c68b |
- if [ "${action}" == "start" ]; then
|
|
|
e3c68b |
+ if [[ "${action}" == "start" ]]; then
|
|
|
e3c68b |
option="yes"
|
|
|
e3c68b |
else
|
|
|
e3c68b |
option="no"
|
|
|
e3c68b |
@@ -122,7 +127,7 @@ manage_service ()
|
|
|
e3c68b |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
e3c68b |
${SECRET_PEM} root@${new_node} "${GANESHA_HA_SH} --setup-ganesha-conf-files $HA_CONFDIR $option"
|
|
|
e3c68b |
|
|
|
e3c68b |
- if [ "${SERVICE_MAN}" == "/bin/systemctl" ]
|
|
|
e3c68b |
+ if [[ "${SERVICE_MAN}" == "/bin/systemctl" ]]
|
|
|
e3c68b |
then
|
|
|
e3c68b |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
e3c68b |
${SECRET_PEM} root@${new_node} "${SERVICE_MAN} ${action} nfs-ganesha"
|
|
|
e3c68b |
@@ -140,7 +145,7 @@ check_cluster_exists()
|
|
|
e3c68b |
|
|
|
e3c68b |
if [ -e /var/run/corosync.pid ]; then
|
|
|
e3c68b |
cluster_name=$(pcs status | grep "Cluster name:" | cut -d ' ' -f 3)
|
|
|
e3c68b |
- if [ ${cluster_name} -a ${cluster_name} = ${name} ]; then
|
|
|
e3c68b |
+ if [[ "${cluster_name}X" == "${name}X" ]]; then
|
|
|
e3c68b |
logger "$name already exists, exiting"
|
|
|
e3c68b |
exit 0
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
@@ -155,7 +160,7 @@ determine_servers()
|
|
|
e3c68b |
local tmp_ifs=${IFS}
|
|
|
e3c68b |
local ha_servers=""
|
|
|
e3c68b |
|
|
|
e3c68b |
- if [ "X${cmd}X" != "XsetupX" -a "X${cmd}X" != "XstatusX" ]; then
|
|
|
e3c68b |
+ if [ "${cmd}X" != "setupX" -a "${cmd}X" != "statusX" ]; then
|
|
|
e3c68b |
ha_servers=$(pcs status | grep "Online:" | grep -o '\[.*\]' | sed -e 's/\[//' | sed -e 's/\]//')
|
|
|
e3c68b |
IFS=$' '
|
|
|
e3c68b |
for server in ${ha_servers} ; do
|
|
|
e3c68b |
@@ -193,15 +198,21 @@ setup_cluster()
|
|
|
e3c68b |
|
|
|
e3c68b |
logger "setting up cluster ${name} with the following ${servers}"
|
|
|
e3c68b |
|
|
|
e3c68b |
- pcs cluster auth ${servers}
|
|
|
e3c68b |
- # pcs cluster setup --name ${name} ${servers}
|
|
|
e3c68b |
- pcs cluster setup ${RHEL6_PCS_CNAME_OPTION} ${name} --enable --transport udpu ${servers}
|
|
|
e3c68b |
+ # pcs cluster setup --force ${PCS9OR10_PCS_CNAME_OPTION} ${name} ${servers}
|
|
|
e3c68b |
+ pcs cluster setup --force ${PCS9OR10_PCS_CNAME_OPTION} ${name} --enable ${servers}
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
- logger "pcs cluster setup ${RHEL6_PCS_CNAME_OPTION} ${name} --enable --transport udpu ${servers} failed"
|
|
|
e3c68b |
+ logger "pcs cluster setup ${PCS9OR10_PCS_CNAME_OPTION} ${name} --enable ${servers} failed, shutting down ganesha and bailing out"
|
|
|
e3c68b |
#set up failed stop all ganesha process and clean up symlinks in cluster
|
|
|
e3c68b |
stop_ganesha_all "${servers}"
|
|
|
e3c68b |
exit 1;
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+ # pcs cluster auth ${servers}
|
|
|
e3c68b |
+ pcs cluster auth
|
|
|
e3c68b |
+ if [ $? -ne 0 ]; then
|
|
|
e3c68b |
+ logger "pcs cluster auth failed"
|
|
|
e3c68b |
+ fi
|
|
|
e3c68b |
+
|
|
|
e3c68b |
pcs cluster start --all
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
logger "pcs cluster start failed"
|
|
|
e3c68b |
@@ -217,7 +228,7 @@ setup_cluster()
|
|
|
e3c68b |
done
|
|
|
e3c68b |
|
|
|
e3c68b |
unclean=$(pcs status | grep -u "UNCLEAN")
|
|
|
e3c68b |
- while [[ "${unclean}X" = "UNCLEANX" ]]; do
|
|
|
e3c68b |
+ while [[ "${unclean}X" == "UNCLEANX" ]]; do
|
|
|
e3c68b |
sleep 1
|
|
|
e3c68b |
unclean=$(pcs status | grep -u "UNCLEAN")
|
|
|
e3c68b |
done
|
|
|
e3c68b |
@@ -244,7 +255,7 @@ setup_finalize_ha()
|
|
|
e3c68b |
local stopped=""
|
|
|
e3c68b |
|
|
|
e3c68b |
stopped=$(pcs status | grep -u "Stopped")
|
|
|
e3c68b |
- while [[ "${stopped}X" = "StoppedX" ]]; do
|
|
|
e3c68b |
+ while [[ "${stopped}X" == "StoppedX" ]]; do
|
|
|
e3c68b |
sleep 1
|
|
|
e3c68b |
stopped=$(pcs status | grep -u "Stopped")
|
|
|
e3c68b |
done
|
|
|
e3c68b |
@@ -265,7 +276,7 @@ refresh_config ()
|
|
|
e3c68b |
if [ -e ${SECRET_PEM} ]; then
|
|
|
e3c68b |
while [[ ${3} ]]; do
|
|
|
e3c68b |
current_host=`echo ${3} | cut -d "." -f 1`
|
|
|
e3c68b |
- if [ ${short_host} != ${current_host} ]; then
|
|
|
e3c68b |
+ if [[ ${short_host} != ${current_host} ]]; then
|
|
|
e3c68b |
output=$(ssh -oPasswordAuthentication=no \
|
|
|
e3c68b |
-oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \
|
|
|
e3c68b |
"dbus-send --print-reply --system --dest=org.ganesha.nfsd \
|
|
|
e3c68b |
@@ -398,7 +409,7 @@ wrap_create_virt_ip_constraints()
|
|
|
e3c68b |
# the result is "node2 node3 node4"; for node2, "node3 node4 node1"
|
|
|
e3c68b |
# and so on.
|
|
|
e3c68b |
while [[ ${1} ]]; do
|
|
|
e3c68b |
- if [ "${1}" = "${primary}" ]; then
|
|
|
e3c68b |
+ if [[ ${1} == ${primary} ]]; then
|
|
|
e3c68b |
shift
|
|
|
e3c68b |
while [[ ${1} ]]; do
|
|
|
e3c68b |
tail=${tail}" "${1}
|
|
|
e3c68b |
@@ -429,15 +440,15 @@ setup_create_resources()
|
|
|
e3c68b |
local cibfile=$(mktemp -u)
|
|
|
e3c68b |
|
|
|
e3c68b |
# fixup /var/lib/nfs
|
|
|
e3c68b |
- logger "pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} --clone"
|
|
|
e3c68b |
- pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} --clone
|
|
|
e3c68b |
+ logger "pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} ${PCS9OR10_PCS_CLONE_OPTION}"
|
|
|
e3c68b |
+ pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} ${PCS9OR10_PCS_CLONE_OPTION}
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
- logger "warning: pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} --clone failed"
|
|
|
e3c68b |
+ logger "warning: pcs resource create nfs_setup ocf:heartbeat:ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} ${PCS9OR10_PCS_CLONE_OPTION} failed"
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
|
|
|
e3c68b |
- pcs resource create nfs-mon ocf:heartbeat:ganesha_mon --clone
|
|
|
e3c68b |
+ pcs resource create nfs-mon ocf:heartbeat:ganesha_mon ${PCS9OR10_PCS_CLONE_OPTION}
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
- logger "warning: pcs resource create nfs-mon ocf:heartbeat:ganesha_mon --clone failed"
|
|
|
e3c68b |
+ logger "warning: pcs resource create nfs-mon ocf:heartbeat:ganesha_mon ${PCS9OR10_PCS_CLONE_OPTION} failed"
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
|
|
|
e3c68b |
# see comment in (/usr/lib/ocf/resource.d/heartbeat/ganesha_grace
|
|
|
e3c68b |
@@ -445,9 +456,9 @@ setup_create_resources()
|
|
|
e3c68b |
# ganesha-active crm_attribute
|
|
|
e3c68b |
sleep 5
|
|
|
e3c68b |
|
|
|
e3c68b |
- pcs resource create nfs-grace ocf:heartbeat:ganesha_grace --clone notify=true
|
|
|
e3c68b |
+ pcs resource create nfs-grace ocf:heartbeat:ganesha_grace ${PCS9OR10_PCS_CLONE_OPTION} notify=true
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
- logger "warning: pcs resource create nfs-grace ocf:heartbeat:ganesha_grace --clone failed"
|
|
|
e3c68b |
+ logger "warning: pcs resource create nfs-grace ocf:heartbeat:ganesha_grace ${PCS9OR10_PCS_CLONE_OPTION} failed"
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
|
|
|
e3c68b |
pcs constraint location nfs-grace-clone rule score=-INFINITY grace-active ne 1
|
|
|
e3c68b |
@@ -616,7 +627,7 @@ addnode_recreate_resources()
|
|
|
e3c68b |
--after ${add_node}-nfs_block
|
|
|
e3c68b |
if [ $? -ne 0 ]; then
|
|
|
e3c68b |
logger "warning pcs resource create ${add_node}-cluster_ip-1 ocf:heartbeat:IPaddr \
|
|
|
e3c68b |
- ip=${add_vip} cidr_netmask=32 op monitor interval=15s failed"
|
|
|
e3c68b |
+ ip=${add_vip} cidr_netmask=32 op monitor interval=15s failed"
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
|
|
|
e3c68b |
pcs -f ${cibfile} constraint order nfs-grace-clone then ${add_node}-cluster_ip-1
|
|
|
e3c68b |
@@ -780,7 +791,7 @@ setup_state_volume()
|
|
|
e3c68b |
touch ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
for server in ${HA_SERVERS} ; do
|
|
|
e3c68b |
- if [ ${server} != ${dirname} ]; then
|
|
|
e3c68b |
+ if [[ ${server} != ${dirname} ]]; then
|
|
|
e3c68b |
ln -s ${mnt}/nfs-ganesha/${server}/nfs/ganesha ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/${server}
|
|
|
e3c68b |
ln -s ${mnt}/nfs-ganesha/${server}/nfs/statd ${mnt}/nfs-ganesha/${dirname}/nfs/statd/${server}
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
@@ -794,7 +805,7 @@ setup_state_volume()
|
|
|
e3c68b |
enable_pacemaker()
|
|
|
e3c68b |
{
|
|
|
e3c68b |
while [[ ${1} ]]; do
|
|
|
e3c68b |
- if [ "${SERVICE_MAN}" == "/usr/bin/systemctl" ]; then
|
|
|
e3c68b |
+ if [[ "${SERVICE_MAN}" == "/bin/systemctl" ]]; then
|
|
|
e3c68b |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
e3c68b |
${SECRET_PEM} root@${1} "${SERVICE_MAN} enable pacemaker"
|
|
|
e3c68b |
else
|
|
|
e3c68b |
@@ -892,7 +903,7 @@ delnode_state_volume()
|
|
|
e3c68b |
rm -rf ${mnt}/nfs-ganesha/${dirname}
|
|
|
e3c68b |
|
|
|
e3c68b |
for server in ${HA_SERVERS} ; do
|
|
|
e3c68b |
- if [[ "${server}" != "${dirname}" ]]; then
|
|
|
e3c68b |
+ if [[ ${server} != ${dirname} ]]; then
|
|
|
e3c68b |
rm -f ${mnt}/nfs-ganesha/${server}/nfs/ganesha/${dirname}
|
|
|
e3c68b |
rm -f ${mnt}/nfs-ganesha/${server}/nfs/statd/${dirname}
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
@@ -963,7 +974,7 @@ status()
|
|
|
e3c68b |
|
|
|
e3c68b |
create_ganesha_conf_file()
|
|
|
e3c68b |
{
|
|
|
e3c68b |
- if [ $1 == "yes" ];
|
|
|
e3c68b |
+ if [[ "$1" == "yes" ]];
|
|
|
e3c68b |
then
|
|
|
e3c68b |
if [ -e $GANESHA_CONF ];
|
|
|
e3c68b |
then
|
|
|
e3c68b |
@@ -1012,6 +1023,13 @@ main()
|
|
|
e3c68b |
semanage boolean -m gluster_use_execmem --on
|
|
|
e3c68b |
fi
|
|
|
e3c68b |
|
|
|
e3c68b |
+ local osid=""
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+ osid=$(grep ^ID= /etc/os-release)
|
|
|
e3c68b |
+ eval $(echo ${osid} | grep -F ID=)
|
|
|
e3c68b |
+ osid=$(grep ^VERSION_ID= /etc/os-release)
|
|
|
e3c68b |
+ eval $(echo ${osid} | grep -F VERSION_ID=)
|
|
|
e3c68b |
+
|
|
|
e3c68b |
HA_CONFDIR=${1%/}; shift
|
|
|
e3c68b |
local ha_conf=${HA_CONFDIR}/ganesha-ha.conf
|
|
|
e3c68b |
local node=""
|
|
|
e3c68b |
@@ -1032,7 +1050,17 @@ main()
|
|
|
e3c68b |
|
|
|
e3c68b |
determine_servers "setup"
|
|
|
e3c68b |
|
|
|
e3c68b |
- if [ "X${HA_NUM_SERVERS}X" != "X1X" ]; then
|
|
|
e3c68b |
+ # Fedora 29+ and rhel/centos 8 has PCS-0.10.x
|
|
|
e3c68b |
+ # default is pcs-0.10.x options but check for
|
|
|
e3c68b |
+ # rhel/centos 7 (pcs-0.9.x) and adjust accordingly
|
|
|
e3c68b |
+ if [[ ${ID} =~ {rhel,centos} ]]; then
|
|
|
e3c68b |
+ if [[ ${VERSION_ID} == 7.* ]]; then
|
|
|
e3c68b |
+ PCS9OR10_PCS_CNAME_OPTION="--name"
|
|
|
e3c68b |
+ PCS9OR10_PCS_CLONE_OPTION="--clone"
|
|
|
e3c68b |
+ fi
|
|
|
e3c68b |
+ fi
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+ if [[ "${HA_NUM_SERVERS}X" != "1X" ]]; then
|
|
|
e3c68b |
|
|
|
e3c68b |
determine_service_manager
|
|
|
e3c68b |
|
|
|
e3c68b |
--
|
|
|
e3c68b |
1.8.3.1
|
|
|
e3c68b |
|