summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Visage <hvjunk@gmail.com>2017-05-19 12:21:37 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2017-06-20 12:42:01 +0000
commit3183ca1bdee9cb0af22c017e3c610add8ff2b405 (patch)
tree7fc3036b96154701853ce8826bf129a71ca42af3
parenta052b413242783f39cb3312a6a02bdd025b10f0c (diff)
downloadglusterfs-3183ca1bdee9cb0af22c017e3c610add8ff2b405.tar.gz
glusterfs-3183ca1bdee9cb0af22c017e3c610add8ff2b405.tar.xz
glusterfs-3183ca1bdee9cb0af22c017e3c610add8ff2b405.zip
scripts/shared_storage : systemd helper scripts to mount shared storage post reboot
Reported-by: Hendrik Visage <hvjunk@gmail.com> Change-Id: Ibcff56b00f45c8af54c1ae04974267c2180f5f63 BUG: 1452527 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: https://review.gluster.org/17339 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
-rw-r--r--configure.ac1
-rw-r--r--extras/Makefile.am6
-rwxr-xr-xextras/mount-shared-storage.sh37
-rw-r--r--extras/systemd/Makefile.am6
-rw-r--r--extras/systemd/glusterfssharedstorage.service.in12
-rw-r--r--glusterfs.spec.in10
6 files changed, 68 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index ffb722c5ee..b1593b30a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,6 +229,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 3af11032f6..68637724a4 100644
--- a/extras/Makefile.am
+++ b/extras/Makefile.am
@@ -1,5 +1,8 @@
addonexecdir = $(GLUSTERFS_LIBEXECDIR)
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,8 @@ 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 clang-checker.sh
+ command-completion/README stop-all-gluster-processes.sh clang-checker.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 0000000000..038a59aaab
--- /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/#.$//' </etc/fstab | grep -c $volume)
+gfm=$(grep -i $volume /proc/mounts | wc -l)
+
+if [ $gfm -lt $gfc ]
+then
+ exit 1
+fi
+
+exit 0
diff --git a/extras/systemd/Makefile.am b/extras/systemd/Makefile.am
index 5b9b117efa..3988b40bce 100644
--- a/extras/systemd/Makefile.am
+++ b/extras/systemd/Makefile.am
@@ -1,9 +1,9 @@
-CLEANFILES = glusterd.service glustereventsd.service
-EXTRA_DIST = glusterd.service.in glustereventsd.service.in
+CLEANFILES = glusterd.service glustereventsd.service glusterfssharedstorage.service
+EXTRA_DIST = glusterd.service.in glustereventsd.service.in glusterfssharedstorage.service.in
if USE_SYSTEMD
# systemddir is already defined through configure.ac
-systemd_DATA = glusterd.service
+systemd_DATA = glusterd.service glusterfssharedstorage.service
if BUILD_EVENTS
systemd_DATA += glustereventsd.service
diff --git a/extras/systemd/glusterfssharedstorage.service.in b/extras/systemd/glusterfssharedstorage.service.in
new file mode 100644
index 0000000000..3bceba8421
--- /dev/null
+++ b/extras/systemd/glusterfssharedstorage.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Mount glusterfs sharedstorage
+Requires=glusterd.service remote-fs-pre.target local-fs.target
+
+[Service]
+ExecStart=@GLUSTERFS_LIBEXECDIR@/mount-shared-storage.sh
+Restart=on-failure
+RestartSec=3
+RestartForceExitStatus=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index 47cc4c301c..c79e212f63 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -120,6 +120,7 @@
%global _init_glusterd %{_unitdir}/glusterd.service
%global _init_glusterfsd %{_unitdir}/glusterfsd.service
%global _init_glustereventsd %{_unitdir}/glustereventsd.service
+%global _init_glusterfssharedstorage %{_unitdir}/glusterfssharedstorage.service
%else
%global _init_enable() /sbin/chkconfig --add %1 ;
%global _init_disable() /sbin/chkconfig --del %1 ;
@@ -1175,6 +1176,9 @@ exit 0
%if ( 0%{_for_fedora_koji_builds} )
%_init_glusterfsd
%endif
+%if ( 0%{?_with_systemd:1} )
+%_init_glusterfssharedstorage
+%endif
# binaries
%{_sbindir}/glusterd
@@ -1280,6 +1284,9 @@ exit 0
# Extra utility script
%{_datadir}/glusterfs/scripts/stop-all-gluster-processes.sh
+%if ( 0%{?_with_systemd:1} )
+%{_libexecdir}/glusterfs/mount-shared-storage.sh
+%endif
# Incrementalapi
%{_libexecdir}/glusterfs/glusterfind
@@ -1311,6 +1318,9 @@ exit 0
%endif
%changelog
+* Fri Jun 16 2017 Jiffin Tony Thottan <jthottan@redhat.com>
+- Add glusterfssharedstorage.service systemd file
+
* Fri Jun 9 2017 Poornima G <pgurusid@redhat.com>
- Install /var/lib/glusterd/groups/nl-cache by default