From b45d1de28c5bc3806af09e2753c5f3396ca9e199 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 13 Jul 2016 12:09:43 +0530 Subject: [PATCH 60/86] ganesha/scripts : Modifying ganesha-ha.sh for share storage related changes Currently the ganesha related configurations are "scp"ied for operations like add, delete, refresh-config in ganesha-ha.sh. This is no more required since all the conf files are available in shared storage and every node can directly access them from shared storage. More details can be found at http://review.gluster.org/#/c/15105/ Upstream reference: >Change-Id: Ic025eb4dc246db61d6fbe969ca60214751fbf3ba >BUG: 1355956 >Signed-off-by: Jiffin Tony Thottan >Reviewed-on: http://review.gluster.org/14909 >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: soumya k >Smoke: Gluster Build System >Reviewed-by: Kaleb KEITHLEY >Signed-off-by: Jiffin Tony Thottan Change-Id: Ic025eb4dc246db61d6fbe969ca60214751fbf3ba BUG: 1348962 Signed-off-by: Jiffin Tony Thottan Reviewed-on: https://code.engineering.redhat.com/gerrit/84779 Reviewed-by: Atin Mukherjee --- extras/ganesha/scripts/ganesha-ha.sh | 76 +++++---------------------------- 1 files changed, 12 insertions(+), 64 deletions(-) diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh index ada21cb..de7c425 100644 --- a/extras/ganesha/scripts/ganesha-ha.sh +++ b/extras/ganesha/scripts/ganesha-ha.sh @@ -106,6 +106,16 @@ manage_service () { local action=${1} local new_node=${2} + local option= + + if [ "$action" == "start" ]; then + option="yes" + else + option="no" + fi + ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ +${SECRET_PEM} root@${new_node} "/usr/libexec/ganesha/ganesha-ha.sh --setup-ganesha-conf-files $HA_CONFDIR $option" + if [ "$SERVICE_MAN" == "/usr/bin/systemctl" ] then ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ @@ -224,48 +234,20 @@ setup_finalize_ha() } -setup_copy_config() -{ - local short_host=$(hostname -s) - local tganesha_conf=$(mktemp -u) - - if [ -e ${SECRET_PEM} ]; then - while [[ ${1} ]]; do - current_host=`echo ${1} | cut -d "." -f 1` - if [ ${short_host} != ${current_host} ]; then - scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ -${SECRET_PEM} ${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/ - if [ $? -ne 0 ]; then - logger "warning: scp ganesha-ha.conf to ${1} failed" - fi - fi - shift - done - else - logger "warning: scp ganesha-ha.conf to ${1} failed" - fi -} - refresh_config () { local short_host=$(hostname -s) local VOL=${1} local HA_CONFDIR=${2} - local tganesha_vol_conf=$(mktemp) local short_host=$(hostname -s) - cp ${HA_CONFDIR}/exports/export.$VOL.conf \ -${tganesha_vol_conf} + removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\ +grep Export_Id | awk -F"[=,;]" '{print$2}' | tr -d '[[:space:]]'` if [ -e ${SECRET_PEM} ]; then while [[ ${3} ]]; do current_host=`echo ${3} | cut -d "." -f 1` if [ ${short_host} != ${current_host} ]; then - removed_id=$(ssh -oPasswordAuthentication=no \ --oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \ -"cat $HA_CONFDIR/exports/export.$VOL.conf |\ -grep Export_Id | awk -F\"[=,;]\" '{print \$2}' | tr -d '[[:space:]]'") - output=$(ssh -oPasswordAuthentication=no \ -oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \ "dbus-send --print-reply --system --dest=org.ganesha.nfsd \ @@ -278,14 +260,6 @@ uint16:$removed_id 2>&1") exit 1 fi sleep 1 - sed -i s/Export_Id.*/"Export_Id= $removed_id ;"/ \ - ${tganesha_vol_conf} - - scp -q -oPasswordAuthentication=no \ --oStrictHostKeyChecking=no -i \ -${SECRET_PEM} ${tganesha_vol_conf} \ -${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf - output=$(ssh -oPasswordAuthentication=no \ -oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \ "dbus-send --print-reply --system --dest=org.ganesha.nfsd \ @@ -310,8 +284,6 @@ string:\"EXPORT(Path=/$VOL)\" 2>&1") fi # Run the same command on the localhost, - removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\ -grep Export_Id | awk -F"[=,;]" '{print$2}' | tr -d '[[:space:]]'` output=$(dbus-send --print-reply --system --dest=org.ganesha.nfsd \ /org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.RemoveExport \ uint16:$removed_id 2>&1) @@ -334,22 +306,6 @@ string:"EXPORT(Path=/$VOL)" 2>&1) else echo "Success: refresh-config completed." fi - rm -f ${tganesha_vol_conf} - -} - -copy_export_config () -{ - local new_node=${1} - - # The add node should be executed from one of the nodes in ganesha - # cluster. So all the configuration file will be available in that - # node itself. So just copy that to new node - scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ -${SECRET_PEM} ${GANESHA_CONF} ${new_node}:${GANESHA_CONF} - - scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \ -${SECRET_PEM} ${HA_CONFDIR}/exports/ ${new_node}:${HA_CONFDIR}/ } @@ -870,8 +826,6 @@ main() setup_state_volume ${HA_SERVERS} - setup_copy_config ${HA_SERVERS} - else logger "insufficient servers for HA, aborting" @@ -898,8 +852,6 @@ main() logger "adding ${node} with ${vip} to ${HA_NAME}" - copy_export_config ${node} ${HA_CONFDIR} - determine_service_manager manage_service "start" ${node} @@ -925,8 +877,6 @@ main() sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \ $HA_CONFDIR/ganesha-ha.conf HA_SERVERS="${HA_SERVERS} ${node}" - - setup_copy_config ${HA_SERVERS} ;; delete | --delete) @@ -945,8 +895,6 @@ $HA_CONFDIR/ganesha-ha.conf deletenode_update_haconfig ${node} - setup_copy_config ${HA_SERVERS} - rm -rf ${HA_VOL_MNT}/nfs-ganesha/${node} determine_service_manager -- 1.7.1