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