From 31bdb2c85a4418c42fca892533eb95104580218c Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Fri, 16 Dec 2016 07:32:40 -0500 Subject: [PATCH 244/246] common-ha: add node create new node dirs in shared storage When adding a node to the ganesha HA cluster, create the directory tree in shared storage for the added node and create sets of symlinks to match what is/was created for the other nodes. I.e. in a four node cluster the new node needs a set of links to the four existing nodes: /run/gluster/shared/nfs-ganesha/$new/nfs/{ganesha,statd}/$e1 -> e1 /run/gluster/shared/nfs-ganesha/$new/nfs/{ganesha,statd}/$e2 -> e2 /run/gluster/shared/nfs-ganesha/$new/nfs/{ganesha,statd}/$e3 -> e3 /run/gluster/shared/nfs-ganesha/$new/nfs/{ganesha,statd}/$e4 -> e4 and all the existing nodes need links added for the new node: /run/gluster/shared/nfs-ganesha/$e1/nfs/{ganesha,statd}/$new -> new /run/gluster/shared/nfs-ganesha/$e2/nfs/{ganesha,statd}/$new -> new /run/gluster/shared/nfs-ganesha/$e3/nfs/{ganesha,statd}/$new -> new /run/gluster/shared/nfs-ganesha/$e5/nfs/{ganesha,statd}/$new -> new Likewise when deleting, remove the dir and symlinks. upstream master change ID Id2f78f70946f29c3503e1e6db141b66cb431e0ea upstream master bz: 1400613 upstream master http://review.gluster.org/16036 Change-Id: Ibb8aebc54b61429e6a3e9b2b6fa3bb16809240c7 BUG: 1400599 Signed-off-by: Kaleb S. KEITHLEY Reviewed-on: https://code.engineering.redhat.com/gerrit/93172 Reviewed-by: Jiffin Thottan Reviewed-by: Soumya Koduri Reviewed-by: Atin Mukherjee --- extras/ganesha/scripts/ganesha-ha.sh | 95 +++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh index 020ad3e..99b71e7 100644 --- a/extras/ganesha/scripts/ganesha-ha.sh +++ b/extras/ganesha/scripts/ganesha-ha.sh @@ -800,6 +800,96 @@ setup_state_volume() } +addnode_state_volume() +{ + local newnode=${1}; shift + local mnt=${HA_VOL_MNT} + local longname="" + local dname="" + local dirname="" + + longname=$(hostname) + dname=${longname#$(hostname -s)} + + if [[ ${newnode} == *${dname} ]]; then + dirname=${newnode} + else + dirname=${newnode}${dname} + fi + + if [ ! -d ${mnt}/nfs-ganesha/tickle_dir ]; then + mkdir ${mnt}/nfs-ganesha/tickle_dir + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname} ]; then + mkdir ${mnt}/nfs-ganesha/${dirname} + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd + fi + if [ ! -e ${mnt}/nfs-ganesha/${dirname}/nfs/state ]; then + touch ${mnt}/nfs-ganesha/${dirname}/nfs/state + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4recov + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4old ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/v4old + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm + fi + if [ ! -d ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak ]; then + mkdir ${mnt}/nfs-ganesha/${dirname}/nfs/statd/sm.bak + fi + if [ ! -e ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state ]; then + touch ${mnt}/nfs-ganesha/${dirname}/nfs/statd/state + fi + + for server in ${HA_SERVERS} ; do + ln -s ${mnt}/nfs-ganesha/${server}/nfs/ganesha ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha/${server} + ln -s ${mnt}/nfs-ganesha/${server}/nfs/statd ${mnt}/nfs-ganesha/${dirname}/nfs/statd/${server} + + ln -s ${mnt}/nfs-ganesha/${dirname}/nfs/ganesha ${mnt}/nfs-ganesha/${server}/nfs/ganesha/${dirname} + ln -s ${mnt}/nfs-ganesha/${dirname}/nfs/statd ${mnt}/nfs-ganesha/${server}/nfs/statd/${dirname} + done + +} + + +delnode_state_volume() +{ + local delnode=${1}; shift + local mnt=${HA_VOL_MNT} + local longname="" + local dname="" + local dirname="" + + longname=$(hostname) + dname=${longname#$(hostname -s)} + + if [[ ${delnode} == *${dname} ]]; then + dirname=${delnode} + else + dirname=${delnode}${dname} + fi + + rm -rf ${mnt}/nfs-ganesha/${dirname} + + for server in ${HA_SERVERS} ; do + if [[ "${server}" != "${dirname}" ]]; then + rm -f ${mnt}/nfs-ganesha/${server}/nfs/ganesha/${dirname} + rm -f ${mnt}/nfs-ganesha/${server}/nfs/statd/${dirname} + fi + done +} + + status() { local scratch=$(mktemp) @@ -989,6 +1079,9 @@ main() sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \ $HA_CONFDIR/ganesha-ha.conf + + addnode_state_volume ${node} + HA_SERVERS="${HA_SERVERS} ${node}" HA_NUM_SERVERS=$(expr ${HA_NUM_SERVERS} + 1) @@ -1011,7 +1104,7 @@ $HA_CONFDIR/ganesha-ha.conf deletenode_update_haconfig ${node} - rm -rf ${HA_VOL_MNT}/nfs-ganesha/${node} + delnode_state_volume ${node} determine_service_manager -- 2.9.3