Skip to content

Commit

Permalink
stop.sh: unmap rbd images when stopping the whole cluster
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
idryomov committed Apr 3, 2014
1 parent afc5dc5 commit 8e46fe0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8e46fe0

Please sign in to comment.