coren has submitted this change and it was merged.

Change subject: Labs: make reboot-if-idmap smarter
......................................................................


Labs: make reboot-if-idmap smarter

It will now try to unmount all NFS filesystems and reload
the kernel module before it tries to reboot the instance.

Change-Id: Ia3fbd52b8c434964e8e1420fdc00262b3fd8c668
---
M files/nfs/reboot-if-idmap
1 file changed, 23 insertions(+), 2 deletions(-)

Approvals:
  Andrew Bogott: Looks good to me, but someone else must approve
  coren: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/files/nfs/reboot-if-idmap b/files/nfs/reboot-if-idmap
index dd96526..2cccadf 100644
--- a/files/nfs/reboot-if-idmap
+++ b/files/nfs/reboot-if-idmap
@@ -9,17 +9,38 @@
 testfile="/home/._._testfile"
 
 if [ -e $testfile ]; then
-    echo "$testfile: already exists\n" >&2
+    echo "$testfile: already exists\n"
     exit 1
 fi
 
 trap "rm -f $testfile" 0
 
-if ! touch $testfile; then
+if ! touch $testfile 2>/dev/null; then
+    echo "$testfile: unable to create\n"
     exit 1
 fi
 
 if ! chown 456 $testfile 2>/dev/null; then
     # UID 456 picked because known to not be on labstore
+
+    # Rather than reboot outright, try to unmount the NFS
+    # filesystems and unload the kernel module.  This will
+    # fail if anything is using NFS but will prevent a
+    # needless reboot for instances that aren't actually
+    # using it at this time.
+
+    if /bin/umount -a -t nfs 2>/dev/null; then
+        if /sbin/rmmod nfs 2>/dev/null; then
+            if /sbin/modprobe nfs 2>/dev/null; then
+                if /bin/mount -a -t nfs 2>/dev/null; then
+                    echo "skipped - was able to reload the module"
+                    exit 1
+                fi
+            fi
+        fi
+    fi
+
     /sbin/reboot
+    echo "rebooting"
+    exit 0
 fi

-- 
To view, visit https://gerrit.wikimedia.org/r/206116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3fbd52b8c434964e8e1420fdc00262b3fd8c668
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: coren <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: coren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to