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.

Change-Id: Id2f78f70946f29c3503e1e6db141b66cb431e0ea
BUG: 1400613
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/16036
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: soumya k <skoduri@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
This commit is contained in:
Kaleb S. KEITHLEY 2016-12-06 02:00:11 -05:00 committed by Kaleb KEITHLEY
parent 2d87431c51
commit dc549b330c

View File

@ -779,6 +779,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)
@ -968,6 +1058,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)
@ -990,7 +1083,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