From c2be72f55be489156b9fbc2250cd27cb32995790 Mon Sep 17 00:00:00 2001 From: Hendrik Visage Date: Fri, 19 May 2017 12:21:37 +0530 Subject: [PATCH 523/525] scripts/shared_storage : systemd helper scripts to mount shared storage post reboot Upstream reference : >Reported-by: Hendrik Visage >Change-Id: Ibcff56b00f45c8af54c1ae04974267c2180f5f63 >BUG: 1452527 >Signed-off-by: Jiffin Tony Thottan >Reviewed-on: https://review.gluster.org/17339 >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: Niels de Vos >Reviewed-by: Kaleb KEITHLEY Change-Id: Ibcff56b00f45c8af54c1ae04974267c2180f5f63 BUG: 1335090 Signed-off-by: Jiffin Tony Thottan Reviewed-on: https://code.engineering.redhat.com/gerrit/109602 Reviewed-by: Milind Changire Reviewed-by: Atin Mukherjee --- configure.ac | 1 + extras/Makefile.am | 5 +++- extras/mount-shared-storage.sh | 37 ++++++++++++++++++++++++ extras/systemd/Makefile.am | 6 ++-- extras/systemd/glusterfssharedstorage.service.in | 12 ++++++++ glusterfs.spec.in | 10 +++++++ 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 extras/mount-shared-storage.sh create mode 100644 extras/systemd/glusterfssharedstorage.service.in diff --git a/configure.ac b/configure.ac index 22272d4..f532ea1 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,7 @@ AC_CONFIG_FILES([Makefile extras/systemd/Makefile extras/systemd/glusterd.service extras/systemd/glustereventsd.service + extras/systemd/glusterfssharedstorage.service extras/run-gluster.tmpfiles extras/benchmarking/Makefile extras/hook-scripts/Makefile diff --git a/extras/Makefile.am b/extras/Makefile.am index 96b1b2b..5a340da 100644 --- a/extras/Makefile.am +++ b/extras/Makefile.am @@ -1,5 +1,8 @@ addonexecdir = $(libexecdir)/glusterfs addonexec_SCRIPTS = peer_add_secret_pub +if USE_SYSTEMD +addonexec_SCRIPTS += mount-shared-storage.sh +endif EditorModedir = $(docdir) EditorMode_DATA = glusterfs-mode.el glusterfs.vim @@ -22,7 +25,7 @@ EXTRA_DIST = $(conf_DATA) specgen.scm glusterfs-mode.el glusterfs.vim \ disk_usage_sync.sh clear_xattrs.sh glusterd-sysconfig glusterd.vol \ post-upgrade-script-for-quota.sh pre-upgrade-script-for-quota.sh \ command-completion/gluster.bash command-completion/Makefile \ - command-completion/README stop-all-gluster-processes.sh + command-completion/README stop-all-gluster-processes.sh mount-shared-storage.sh install-data-local: if [ -n "$(tmpfilesdir)" ]; then \ diff --git a/extras/mount-shared-storage.sh b/extras/mount-shared-storage.sh new file mode 100755 index 0000000..038a59a --- /dev/null +++ b/extras/mount-shared-storage.sh @@ -0,0 +1,37 @@ +#!/bin/bash +#Post reboot there is a chance in which mounting of shared storage will fail +#This will impact starting of features like NFS-Ganesha. So this script will +#try to mount the shared storage if it fails +#TODO : Do it for other glusterfs clients in /etc/fstab + +ms="var-run-gluster-shared_storage.mount" +volume="gluster_shared_storage" +failed=$(systemctl --failed | grep -c $ms) +if [ $failed -eq 1 ] +then + if systemctl restart $ms + then + #Restart worked just wait for sometime to make it reflect + sleep 5 + else + #Restart failed, no point in further continuing + exit 1 + fi +fi + +# If we've reached this point, there wasn't a failed mountpoint +# BUT we need to check for whether this haven't been called before the attempts +# to the filesystem mounts, thus we need to check whether there is a glusterfs +# in fstab and aren't mountedmount + +#In the logs I've seen ~4-5secs between the initial mount/start and the unmount + +gfc=$(sed -e 's/#.$//' +- Add glusterfssharedstorage.service systemd file + * Tue Jun 13 2017 Poornima G - Install /var/lib/glusterd/groups/nl-cache by default -- 1.8.3.1