From 8dcc5596c5370fcbee6ac8fc89cc90ff1d5fd29a Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 12 Jan 2016 17:35:34 +0100 Subject: scripts: prevent running 'showmount' from the start/post hook script The 31ganesha-start.sh hook script tries to run 'showmount' to see if the volume that is getting started should get exported by NFS-Ganesha. It was reported that this caused the 'gluster volume start ...' command to hang in case rpcbind is not running. Instead of running 'showmount', we can use DBus to contact NFS-Ganesha directly, and request the available exports. This will immediately fail in case NFS-Ganesha is not running. Cherry picked from commit 2b2294d2a4ef221fccb6eb9f74e9b7dc233b9f1d: > BUG: 1294446 > Change-Id: I3aba1f86fead67116ca5adb1864a8be626c334fa > Reported-by: Jeff Darcy > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/13098 > Tested-by: Raghavendra Talur > Reviewed-by: jiffin tony Thottan > Reviewed-by: Kaleb KEITHLEY BUG: 1297862 Change-Id: I3aba1f86fead67116ca5adb1864a8be626c334fa Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/13230 Tested-by: NetBSD Build System Reviewed-by: Kaleb KEITHLEY --- extras/hook-scripts/start/post/S31ganesha-start.sh | 54 +++++++++++++++------- glusterfs.spec.in | 5 +- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh index 9ca07e5a8d6..b85c789b9ed 100755 --- a/extras/hook-scripts/start/post/S31ganesha-start.sh +++ b/extras/hook-scripts/start/post/S31ganesha-start.sh @@ -103,23 +103,43 @@ function start_ganesha() } - parse_args $@ - is_exported="no" - if showmount -e localhost | cut -d "" -f1 | grep -q "/$VOL[[:space:]]" - then - is_exported="yes" - fi - ganesha_value=$(grep $ganesha_key $GLUSTERD_WORKDIR/vols/$VOL/info |\ - cut -d"=" -f2) - if [ "$ganesha_value" = "on" -a "$is_exported" = "no" ] +# based on src/scripts/ganeshactl/Ganesha/export_mgr.py +function is_exported() +{ + local volume="${1}" + + dbus-send --type=method_call --print-reply --system \ + --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \ + org.ganesha.nfsd.exportmgr.ShowExports \ + | grep -w -q "/${volume}" + + return $? +} + +# Check the info file (contains the volume options) to see if Ganesha is +# enabled for this volume. +function ganesha_enabled() +{ + local volume="${1}" + local info_file="${GLUSTERD_WORKDIR}/vols/${VOL}/info" + local enabled="off" + + enabled=$(grep -w ${ganesha_key} ${info_file} | cut -d"=" -f2) + + [ "${enabled}" == "on" ] + + return $? +} + +parse_args $@ + +if ganesha_enabled ${VOL} && ! is_exported ${VOL} +then + if [ ! -e ${GANESHA_DIR}/exports/export.${VOL}.conf ] then - if [ ! -e $GANESHA_DIR/exports/export.$VOL.conf ] - then - write_conf $VOL > $GANESHA_DIR/exports/export.$VOL.conf - fi - start_ganesha $VOL - else - exit 0 + write_conf ${VOL} > ${GANESHA_DIR}/exports/export.${VOL}.conf fi + start_ganesha ${VOL} +fi - +exit 0 diff --git a/glusterfs.spec.in b/glusterfs.spec.in index a74bf7f6fed..69195784185 100644 --- a/glusterfs.spec.in +++ b/glusterfs.spec.in @@ -374,7 +374,7 @@ Group: Applications/File Requires: %{name}-server = %{version}-%{release} Requires: nfs-ganesha-gluster -Requires: pcs +Requires: pcs, /usr/bin/dbus-send %description ganesha GlusterFS is a distributed file-system capable of scaling to several @@ -1268,6 +1268,9 @@ fi %changelog +* Mon Dec 28 2015 Niels de Vos +- hook scripts in glusterfs-ganesha use dbus-send, add dependency (#1294446) + * Tue Sep 15 2015 Anand Nekkunti - adding glusterfs-firewalld service (#1057295) -- cgit