]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
stop.sh: unmap rbd images when stopping the whole cluster 1596/head
authorIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 1 Apr 2014 06:18:23 +0000 (10:18 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Thu, 3 Apr 2014 14:14:57 +0000 (18:14 +0400)
Unmap rbd images when stopping the whole cluster.  Not doing so results
in images that cannot be unmapped until the same cluster is brought
back up.  Issue a warning if we failed to unmap all images.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
src/stop.sh

index 9a5b8d2cc8d5aceec5fa976ef1541e85ee6784ea..d7ce234c1fc57f7e62c68da0241db73b3d0d8d97 100755 (executable)
@@ -18,6 +18,8 @@
 
 test -d dev/osd0/. && test -e dev/sudo && SUDO="sudo"
 
+[ -z "$CEPH_BIN" ] && CEPH_BIN=.
+
 do_killall() {
     pg=`pgrep -f ceph-run.*$1`
     [ -n "$pg" ] && kill $pg
@@ -57,6 +59,20 @@ while [ $# -ge 1 ]; do
 done
 
 if [ $stop_all -eq 1 ]; then
+    while read DEV; do
+        # While it is currently possible to create an rbd image with
+        # whitespace chars in its name, krbd will refuse mapping such
+        # an image, so we can safely split on whitespace here.  (The
+        # same goes for whitespace chars in names of the pools that
+        # contain rbd images).
+        DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
+        sudo "${CEPH_BIN}"/rbd unmap "${DEV}"
+    done < <("${CEPH_BIN}"/rbd showmapped | tail -n +2)
+
+    if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then
+        echo "WARNING: Some rbd images are still mapped!" >&2
+    fi
+
     for p in ceph-mon ceph-mds ceph-osd radosgw lt-radosgw apache2 ; do
         for try in 0 1 1 1 1 ; do
             if ! pkill $p ; then
@@ -65,6 +81,7 @@ if [ $stop_all -eq 1 ]; then
             sleep $try
         done
     done
+
     pkill -f valgrind.bin.\*ceph-mon
     $SUDO pkill -f valgrind.bin.\*ceph-osd
     pkill -f valgrind.bin.\*ceph-mds