|
|
7f4c2a |
From 4bee60f04a395aae47856969526a8acac730b73b Mon Sep 17 00:00:00 2001
|
|
|
7f4c2a |
From: Kaleb S. KEITHLEY <kkeithle@redhat.com>
|
|
|
7f4c2a |
Date: Fri, 26 Jun 2015 06:18:27 -0400
|
|
|
7f4c2a |
Subject: [PATCH 155/190] common-ha: fix delete-node
|
|
|
7f4c2a |
|
|
|
7f4c2a |
delete-node is a designed to be "disruptive"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
surgically delete a node from the config and stop nfs-ganesh on that
|
|
|
7f4c2a |
node.
|
|
|
7f4c2a |
|
|
|
7f4c2a |
finish the implementation and fix a few minor issues
|
|
|
7f4c2a |
|
|
|
7f4c2a |
backport
|
|
|
7f4c2a |
>> Change-Id: I964bb72a76ee635b5fc484ec5b541e69eeececcd
|
|
|
7f4c2a |
>> BUG: 1234474
|
|
|
7f4c2a |
>> http://review.gluster.org/11353
|
|
|
7f4c2a |
> Change-Id: Ic06952df8f42f80cfeb82d419757a8b99dff275a
|
|
|
7f4c2a |
> BUG: 1234584
|
|
|
7f4c2a |
> http://review.gluster.org/11427
|
|
|
7f4c2a |
|
|
|
7f4c2a |
Change-Id: I1779d415a5b1797ac84975475ccf264b62e073e8
|
|
|
7f4c2a |
BUG: 1224619
|
|
|
7f4c2a |
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
|
|
|
7f4c2a |
Reviewed-on: https://code.engineering.redhat.com/gerrit/51681
|
|
|
7f4c2a |
---
|
|
|
7f4c2a |
extras/ganesha/scripts/ganesha-ha.sh | 101 +++++++++++++++++++---------------
|
|
|
7f4c2a |
1 files changed, 56 insertions(+), 45 deletions(-)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
7f4c2a |
index 3fa09bd..ccaa3d8 100755
|
|
|
7f4c2a |
--- a/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
7f4c2a |
+++ b/extras/ganesha/scripts/ganesha-ha.sh
|
|
|
7f4c2a |
@@ -22,7 +22,7 @@
|
|
|
7f4c2a |
|
|
|
7f4c2a |
HA_NUM_SERVERS=0
|
|
|
7f4c2a |
HA_SERVERS=""
|
|
|
7f4c2a |
-HA_CONFDIR=""
|
|
|
7f4c2a |
+HA_CONFDIR="/etc/ganesha"
|
|
|
7f4c2a |
HA_VOL_NAME="gluster_shared_storage"
|
|
|
7f4c2a |
HA_VOL_MNT="/var/run/gluster/shared_storage"
|
|
|
7f4c2a |
SERVICE_MAN="DISTRO_NOT_FOUND"
|
|
|
7f4c2a |
@@ -31,6 +31,7 @@ eval $(echo ${cfgline} | grep -F CONFFILE=)
|
|
|
7f4c2a |
GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
RHEL6_PCS_CNAME_OPTION="--name"
|
|
|
7f4c2a |
+SECRET_PEM="/var/lib/glusterd/nfs/secret.pem"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
usage() {
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -69,10 +70,10 @@ manage_service ()
|
|
|
7f4c2a |
if [ "$SERVICE_MAN" == "/usr/sbin/systemctl" ]
|
|
|
7f4c2a |
then
|
|
|
7f4c2a |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha"
|
|
|
7f4c2a |
+${SECRET_PEM} root@${new_node} "$SERVICE_MAN ${action} nfs-ganesha"
|
|
|
7f4c2a |
else
|
|
|
7f4c2a |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}"
|
|
|
7f4c2a |
+${SECRET_PEM} root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}"
|
|
|
7f4c2a |
fi
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -184,15 +185,12 @@ setup_copy_config()
|
|
|
7f4c2a |
local short_host=$(hostname -s)
|
|
|
7f4c2a |
local tganesha_conf=$(mktemp -u)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- if [ -e /var/lib/glusterd/nfs/secret.pem ]; then
|
|
|
7f4c2a |
+ if [ -e ${SECRET_PEM} ]; then
|
|
|
7f4c2a |
while [[ ${1} ]]; do
|
|
|
7f4c2a |
current_host=`echo ${1} | cut -d "." -f 1`
|
|
|
7f4c2a |
if [ ${short_host} != ${current_host} ]; then
|
|
|
7f4c2a |
- cp ${HA_CONFDIR}/ganesha-ha.conf ${tganesha_conf}
|
|
|
7f4c2a |
scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_conf}\
|
|
|
7f4c2a |
- ${1}:${HA_CONFDIR}/ganesha-ha.conf
|
|
|
7f4c2a |
- rm -rf ${tganesha_conf}
|
|
|
7f4c2a |
+${SECRET_PEM} ${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/
|
|
|
7f4c2a |
if [ $? -ne 0 ]; then
|
|
|
7f4c2a |
logger "warning: scp ganesha-ha.conf to ${1} failed"
|
|
|
7f4c2a |
fi
|
|
|
7f4c2a |
@@ -209,27 +207,24 @@ refresh_config ()
|
|
|
7f4c2a |
local short_host=$(hostname -s)
|
|
|
7f4c2a |
local VOL=${1}
|
|
|
7f4c2a |
local HA_CONFDIR=${2}
|
|
|
7f4c2a |
- local tganesha_export=$(mktemp -u)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\
|
|
|
7f4c2a |
grep Export_Id | cut -d " " -f8`
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- if [ -e /var/lib/glusterd/nfs/secret.pem ]; then
|
|
|
7f4c2a |
+ if [ -e ${SECRET_PEM} ]; then
|
|
|
7f4c2a |
while [[ ${3} ]]; do
|
|
|
7f4c2a |
current_host=`echo ${3} | cut -d "." -f 1`
|
|
|
7f4c2a |
if [ ${short_host} != ${current_host} ]; then
|
|
|
7f4c2a |
- cp ${HA_CONFDIR}/exports/export.$VOL.conf ${tganesha_export}
|
|
|
7f4c2a |
scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_export} \
|
|
|
7f4c2a |
-${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf
|
|
|
7f4c2a |
- rm -rf ${tganesha_export}
|
|
|
7f4c2a |
+${SECRET_PEM} ${HA_CONFDIR}/exports/export.$VOL.conf \
|
|
|
7f4c2a |
+${current_host}:${HA_CONFDIR}/exports/
|
|
|
7f4c2a |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --print-reply --system \
|
|
|
7f4c2a |
+${SECRET_PEM} root@${current_host} "dbus-send --print-reply --system \
|
|
|
7f4c2a |
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
|
|
|
7f4c2a |
org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id"
|
|
|
7f4c2a |
sleep 1
|
|
|
7f4c2a |
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --system \
|
|
|
7f4c2a |
+${SECRET_PEM} root@${current_host} "dbus-send --system \
|
|
|
7f4c2a |
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
|
|
|
7f4c2a |
org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \
|
|
|
7f4c2a |
string:\"EXPORT(Path=/$VOL)\""
|
|
|
7f4c2a |
@@ -256,11 +251,23 @@ string:"EXPORT(Path=/$VOL)"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
copy_export_config ()
|
|
|
7f4c2a |
{
|
|
|
7f4c2a |
- local new_node=${1}
|
|
|
7f4c2a |
- scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${GANESHA_CONF} ${new_node}:/etc/ganesha/
|
|
|
7f4c2a |
- scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
-/var/lib/glusterd/nfs/secret.pem ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${new_node}:${HA_CONFDIR}/
|
|
|
7f4c2a |
+ local new_node=${1}
|
|
|
7f4c2a |
+ local tganesha_conf=$(mktemp -u)
|
|
|
7f4c2a |
+ local tganesha_exports=$(mktemp -d)
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+ # avoid prompting for password, even with password-less scp
|
|
|
7f4c2a |
+ # scp $host1:$file $host2:$file prompts for the password
|
|
|
7f4c2a |
+ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
+${SECRET_PEM} ${HA_VOL_SERVER}:${GANESHA_CONF} ${tganesha_conf}
|
|
|
7f4c2a |
+ scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
+${SECRET_PEM} ${tganesha_conf} ${new_node}:${GANESHA_CONF}
|
|
|
7f4c2a |
+ rm -f ${tganesha_conf}
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+ scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
+${SECRET_PEM} ${HA_VOL_SERVER}:${HA_CONFDIR}/exports/ ${tganesha_exports}
|
|
|
7f4c2a |
+ scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
|
|
|
7f4c2a |
+${SECRET_PEM} ${tganesha_exports} ${new_node}:${HA_CONFDIR}/
|
|
|
7f4c2a |
+ rm -rf ${tganesha_exports}
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -706,7 +713,7 @@ deletenode_delete_resources()
|
|
|
7f4c2a |
# recompute their constraints
|
|
|
7f4c2a |
clear_resources ${cibfile} ${HA_SERVERS}
|
|
|
7f4c2a |
recreate_resources ${cibfile} ${ha_servers}
|
|
|
7f4c2a |
- HA_SERVERS="${ha_servers}"
|
|
|
7f4c2a |
+ HA_SERVERS=$(echo "${ha_servers}" | sed -e "s/ / /")
|
|
|
7f4c2a |
|
|
|
7f4c2a |
create_virt_ip_constraints ${cibfile} ${HA_SERVERS}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -804,6 +811,7 @@ setup_state_volume()
|
|
|
7f4c2a |
}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
main()
|
|
|
7f4c2a |
{
|
|
|
7f4c2a |
|
|
|
7f4c2a |
@@ -877,36 +885,36 @@ main()
|
|
|
7f4c2a |
node=${1}; shift
|
|
|
7f4c2a |
vip=${1}; shift
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- logger "adding ${node} with ${vip} to ${HA_NAME}"
|
|
|
7f4c2a |
+ logger "adding ${node} with ${vip} to ${HA_NAME}"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- copy_export_config ${node} ${HA_CONFDIR}
|
|
|
7f4c2a |
+ copy_export_config ${node} ${HA_CONFDIR}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- determine_service_manager
|
|
|
7f4c2a |
+ determine_service_manager
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- manage_service "start" ${node}
|
|
|
7f4c2a |
+ manage_service "start" ${node}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- determine_servers "add"
|
|
|
7f4c2a |
+ determine_servers "add"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- pcs cluster node add ${node}
|
|
|
7f4c2a |
- if [ $? -ne 0 ]; then
|
|
|
7f4c2a |
+ pcs cluster node add ${node}
|
|
|
7f4c2a |
+ if [ $? -ne 0 ]; then
|
|
|
7f4c2a |
logger "warning: pcs cluster node add ${node} failed"
|
|
|
7f4c2a |
- fi
|
|
|
7f4c2a |
+ fi
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- addnode_create_resources ${node} ${vip}
|
|
|
7f4c2a |
- #Subsequent add-node recreates resources for all the nodes
|
|
|
7f4c2a |
- #that already exist in the cluster. The nodes are picked up
|
|
|
7f4c2a |
- #from the entries in the ganesha-ha.conf file. Adding the
|
|
|
7f4c2a |
- #newly added node to the file so that the resources specfic
|
|
|
7f4c2a |
- #to this node is correctly recreated in the future.
|
|
|
7f4c2a |
- echo "VIP_$node=\"$vip\"" >> ${HA_CONFDIR}/ganesha-ha.conf
|
|
|
7f4c2a |
+ addnode_create_resources ${node} ${vip}
|
|
|
7f4c2a |
+ #Subsequent add-node recreates resources for all the nodes
|
|
|
7f4c2a |
+ #that already exist in the cluster. The nodes are picked up
|
|
|
7f4c2a |
+ #from the entries in the ganesha-ha.conf file. Adding the
|
|
|
7f4c2a |
+ #newly added node to the file so that the resources specfic
|
|
|
7f4c2a |
+ #to this node is correctly recreated in the future.
|
|
|
7f4c2a |
+ echo "VIP_$node=\"$vip\"" >> ${HA_CONFDIR}/ganesha-ha.conf
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- NEW_NODES="$HA_CLUSTER_NODES,$node"
|
|
|
7f4c2a |
+ NEW_NODES="$HA_CLUSTER_NODES,$node"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \
|
|
|
7f4c2a |
+ sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \
|
|
|
7f4c2a |
$HA_CONFDIR/ganesha-ha.conf
|
|
|
7f4c2a |
- HA_SERVERS="${HA_SERVERS} ${node}"
|
|
|
7f4c2a |
+ HA_SERVERS="${HA_SERVERS} ${node}"
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- setup_copy_config ${HA_SERVERS}
|
|
|
7f4c2a |
+ setup_copy_config ${HA_SERVERS}
|
|
|
7f4c2a |
;;
|
|
|
7f4c2a |
|
|
|
7f4c2a |
delete | --delete)
|
|
|
7f4c2a |
@@ -923,13 +931,16 @@ $HA_CONFDIR/ganesha-ha.conf
|
|
|
7f4c2a |
logger "warning: pcs cluster node remove ${node} failed"
|
|
|
7f4c2a |
fi
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- # TODO: delete node's directory in shared state
|
|
|
7f4c2a |
+ ha_servers=$(echo ${HA_SERVERS} | sed -e "s/ /,/")
|
|
|
7f4c2a |
+ sed -i "s/^HA_CLUSTER_NODES=.*$/HA_CLUSTER_NODES=\"${ha_servers// /,}\"/" ${HA_CONFDIR}/ganesha-ha.conf
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- determine_service_manager
|
|
|
7f4c2a |
+ setup_copy_config ${HA_SERVERS}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- manage-service "stop"
|
|
|
7f4c2a |
+ rm -rf ${HA_VOL_MNT}/nfs-ganesha/{node}
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- cleanup_ganesha_config ${HA_CONFDIR}
|
|
|
7f4c2a |
+ determine_service_manager
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
+ manage_service "stop" ${node}
|
|
|
7f4c2a |
;;
|
|
|
7f4c2a |
|
|
|
7f4c2a |
status | --status)
|
|
|
7f4c2a |
--
|
|
|
7f4c2a |
1.7.1
|
|
|
7f4c2a |
|