7f4c2a
From 8ac406785cfa18813d1f04bd7587a05e750735d5 Mon Sep 17 00:00:00 2001
7f4c2a
From: Meghana M <mmadhusu@redhat.com>
7f4c2a
Date: Thu, 18 Jun 2015 06:39:41 +0530
7f4c2a
Subject: [PATCH 125/129] common-ha : Fixing add node operation
7f4c2a
7f4c2a
Resource create for the added node referenced a variable
7f4c2a
new_node that was never passed. This led to a wrong schema
7f4c2a
type in the cib file and hence the added node always ended
7f4c2a
up in failed state. And also, resources were wrongly
7f4c2a
created twice and led to more errors. I have fixed the variable
7f4c2a
name and deleted the repetitive invocation of the recreate-resource
7f4c2a
function.
7f4c2a
7f4c2a
The new node has to be added to the existing ganesha-ha config
7f4c2a
file for correct behaviour during subsequent add-node operations.
7f4c2a
This edited file has to be copied to all the other cluster nodes.
7f4c2a
I have added a fix for this as well.
7f4c2a
7f4c2a
This is the backport of the fix merged on master,
7f4c2a
http://review.gluster.org/#/c/11316/
7f4c2a
7f4c2a
Change-Id: I28b585a252f25a85e481c9c420d10e1e30c5dd9a
7f4c2a
BUG: 1228626
7f4c2a
Signed-off-by: Meghana Madhusudhan <mmadhusu@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/51195
7f4c2a
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
7f4c2a
Reviewed-by: Niels de Vos <ndevos@redhat.com>
7f4c2a
Tested-by: Niels de Vos <ndevos@redhat.com>
7f4c2a
---
7f4c2a
 cli/src/cli-rpc-ops.c                |    2 +-
7f4c2a
 extras/ganesha/scripts/ganesha-ha.sh |   64 ++++++++++++++++++++--------------
7f4c2a
 2 files changed, 39 insertions(+), 27 deletions(-)
7f4c2a
7f4c2a
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
7f4c2a
index a834147..57e11fa 100644
7f4c2a
--- a/cli/src/cli-rpc-ops.c
7f4c2a
+++ b/cli/src/cli-rpc-ops.c
7f4c2a
@@ -1976,7 +1976,7 @@ gf_cli_ganesha_cbk (struct rpc_req *req, struct iovec *iov,
7f4c2a
         }
7f4c2a
 
7f4c2a
         else {
7f4c2a
-                cli_out("ganesha enable : success ");
7f4c2a
+                cli_out("nfs-ganesha : success ");
7f4c2a
         }
7f4c2a
 
7f4c2a
         ret = rsp.op_ret;
7f4c2a
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
7f4c2a
index 725b6b4..74c1194 100755
7f4c2a
--- a/extras/ganesha/scripts/ganesha-ha.sh
7f4c2a
+++ b/extras/ganesha/scripts/ganesha-ha.sh
7f4c2a
@@ -53,11 +53,15 @@ determine_service_manager () {
7f4c2a
 
7f4c2a
 manage_service ()
7f4c2a
 {
7f4c2a
+        local action=${1}
7f4c2a
+        local new_node=${2}
7f4c2a
         if [ "$SERVICE_MAN" == "/usr/sbin/systemctl" ]
7f4c2a
         then
7f4c2a
-                $SERVICE_MAN  $1 nfs-ganesha
7f4c2a
+                ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
7f4c2a
+/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN  ${action} nfs-ganesha"
7f4c2a
         else
7f4c2a
-                $SERVICE_MAN nfs-ganesha $1
7f4c2a
+                ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
7f4c2a
+/var/lib/glusterd/nfs/secret.pem root@${new_node} "$SERVICE_MAN nfs-ganesha ${action}"
7f4c2a
         fi
7f4c2a
 }
7f4c2a
 
7f4c2a
@@ -171,7 +175,8 @@ setup_copy_config()
7f4c2a
     if [ -e /var/lib/glusterd/nfs/secret.pem ]; then
7f4c2a
         while [[ ${1} ]]; do
7f4c2a
             if [ ${short_host} != ${1} ]; then
7f4c2a
-                scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i /var/lib/glusterd/nfs/secret.pem /etc/ganesha/ganesha-ha.conf ${1}:/etc/ganesha/
7f4c2a
+                scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
7f4c2a
+/var/lib/glusterd/nfs/secret.pem ${1}:${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
@@ -185,9 +190,11 @@ setup_copy_config()
7f4c2a
 
7f4c2a
 copy_export_config ()
7f4c2a
 {
7f4c2a
-        . /etc/ganesha/ganesha.conf
7f4c2a
-        scp $HA_VOL_SERVER:/etc/ganesha.conf ${1}:/etc/ganesha/
7f4c2a
-        scp -r $HA_VOL_SERVER:$2/exports/ ${1}:${2}/
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
 }
7f4c2a
 
7f4c2a
 
7f4c2a
@@ -547,9 +554,6 @@ clear_resources()
7f4c2a
 
7f4c2a
         shift
7f4c2a
     done
7f4c2a
-
7f4c2a
-    recreate_resources ${cibfile} ${add_node} ${add_vip} ${HA_SERVERS}
7f4c2a
-
7f4c2a
 }
7f4c2a
 
7f4c2a
 
7f4c2a
@@ -570,9 +574,9 @@ addnode_create_resources()
7f4c2a
         logger "warning: pcs -f ${cibfile} resource create nfs_start-${add_node} ganesha_nfsd ha_vol_mnt=${HA_VOL_MNT} failed"
7f4c2a
     fi
7f4c2a
 
7f4c2a
-    pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${newnode}=INFINITY
7f4c2a
+    pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${add_node}=INFINITY
7f4c2a
     if [ $? -ne 0 ]; then
7f4c2a
-        logger "warning: pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${newnode}=INFINITY failed"
7f4c2a
+        logger "warning: pcs -f ${cibfile} constraint location nfs_start-${add_node} prefers ${add_node}=INFINITY failed"
7f4c2a
     fi
7f4c2a
 
7f4c2a
     pcs -f ${cibfile} constraint order nfs_start-${add_node} then nfs-mon-clone
7f4c2a
@@ -802,24 +806,34 @@ main()
7f4c2a
 
7f4c2a
        logger "adding ${node} with ${vip} to ${HA_NAME}"
7f4c2a
 
7f4c2a
-       determine_servers "add"
7f4c2a
+       copy_export_config ${node} ${HA_CONFDIR}
7f4c2a
 
7f4c2a
-        pcs cluster node add ${node}
7f4c2a
-        if [ $? -ne 0 ]; then
7f4c2a
-            logger "warning: pcs cluster node add ${node} failed"
7f4c2a
-        fi
7f4c2a
+       determine_service_manager
7f4c2a
 
7f4c2a
-        addnode_create_resources ${node} ${vip}
7f4c2a
+       manage_service "start" ${node}
7f4c2a
 
7f4c2a
-        setup_state_volume ${node}
7f4c2a
+       determine_servers "add"
7f4c2a
 
7f4c2a
-        setup_copy_config ${node}
7f4c2a
+       pcs cluster node add ${node}
7f4c2a
+       if [ $? -ne 0 ]; then
7f4c2a
+            logger "warning: pcs cluster node add ${node} failed"
7f4c2a
+       fi
7f4c2a
 
7f4c2a
-        copy_export_config ${node} ${HA_CONFDIR}
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
-        determine_service_manager
7f4c2a
+       NEW_NODES="$HA_CLUSTER_NODES,$node"
7f4c2a
 
7f4c2a
-        manage_service "start"
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
+
7f4c2a
+       setup_copy_config ${HA_SERVERS}
7f4c2a
         ;;
7f4c2a
 
7f4c2a
     delete | --delete)
7f4c2a
@@ -838,8 +852,6 @@ main()
7f4c2a
 
7f4c2a
         # TODO: delete node's directory in shared state
7f4c2a
 
7f4c2a
-        teardown_clean_etccluster ${node}
7f4c2a
-
7f4c2a
         determine_service_manager
7f4c2a
 
7f4c2a
         manage-service "stop"
7f4c2a
@@ -856,9 +868,9 @@ main()
7f4c2a
 
7f4c2a
     help | --help)
7f4c2a
         echo "Usage      : add|delete|status"
7f4c2a
-        echo "Add-node   : ganesha-ha.sh --add <HA_CONF_DIR>  \
7f4c2a
+        echo "Add-node   : ganesha-ha.sh --add <HA_CONFDIR>  \
7f4c2a
 <NODE-IP/HOSTNAME>  <NODE-VIP>"
7f4c2a
-        echo "Delete-node: ganesha-ha.sh --delete <HA_CONF_DIR>  \
7f4c2a
+        echo "Delete-node: ganesha-ha.sh --delete <HA_CONFDIR>  \
7f4c2a
 <NODE-IP/HOSTNAME>"
7f4c2a
         ;;
7f4c2a
       *)
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a