Skip to content

Commit

Permalink
Merge pull request #20888 from majianpeng/fix-vstop
Browse files Browse the repository at this point in the history
stop.sh: add ceph configure file location

Reviewed-by: Mykola Golub <mgolub@suse.com>
  • Loading branch information
trociny committed Mar 20, 2018
2 parents 820dac9 + f437598 commit f22a901
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/stop.sh
Expand Up @@ -22,6 +22,13 @@ if [ -e CMakeCache.txt ]; then
[ -z "$CEPH_BIN" ] && CEPH_BIN=bin
fi

if [ -n "$VSTART_DEST" ]; then
CEPH_CONF_PATH=$VSTART_DEST
else
CEPH_CONF_PATH="$PWD"
fi
conf_fn="$CEPH_CONF_PATH/ceph.conf"

MYUID=$(id -u)
MYNAME=$(id -nu)

Expand Down Expand Up @@ -73,19 +80,19 @@ while [ $# -ge 1 ]; do
done

if [ $stop_all -eq 1 ]; then
if "${CEPH_BIN}"/rbd device list >/dev/null 2>&1; then
"${CEPH_BIN}"/rbd device list | tail -n +2 |
if "${CEPH_BIN}"/rbd device list -c $conf_fn >/dev/null 2>&1; then
"${CEPH_BIN}"/rbd device list -c $conf_fn | tail -n +2 |
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 device unmap "${DEV}"
sudo "${CEPH_BIN}"/rbd device unmap "${DEV}" -c $conf_fn
done

if [ -n "$("${CEPH_BIN}"/rbd device list)" ]; then
if [ -n "$("${CEPH_BIN}"/rbd device list -c $conf_fn)" ]; then
echo "WARNING: Some rbd images are still mapped!" >&2
fi
fi
Expand All @@ -102,7 +109,7 @@ if [ $stop_all -eq 1 ]; then
pkill -u $MYUID -f valgrind.bin.\*ceph-mon
$SUDO pkill -u $MYUID -f valgrind.bin.\*ceph-osd
pkill -u $MYUID -f valgrind.bin.\*ceph-mds
asok_dir=`dirname $("${CEPH_BIN}"/ceph-conf --show-config-value admin_socket)`
asok_dir=`dirname $("${CEPH_BIN}"/ceph-conf -c ${conf_fn} --show-config-value admin_socket)`
rm -rf "${asok_dir}"
else
[ $stop_mon -eq 1 ] && do_killall ceph-mon
Expand Down
6 changes: 3 additions & 3 deletions src/vstart.sh
Expand Up @@ -324,7 +324,7 @@ if [ $kill_all -eq 1 ]; then
fi

if [ "$overwrite_conf" -eq 0 ]; then
CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf --show-config-value admin_socket)`
CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)`
mkdir -p $CEPH_ASOK_DIR
MON=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mon 2>/dev/null` && \
CEPH_NUM_MON="$MON"
Expand All @@ -339,7 +339,7 @@ if [ "$overwrite_conf" -eq 0 ]; then
else
if [ "$new" -ne 0 ]; then
# only delete if -n
asok_dir=`dirname $($CEPH_BIN/ceph-conf --show-config-value admin_socket)`
asok_dir=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)`
if [ $asok_dir != /var/run/ceph ]; then
[ -d $asok_dir ] && rm -f $asok_dir/* && rmdir $asok_dir
fi
Expand All @@ -348,7 +348,7 @@ else
fi
[ -e "$conf_fn" ] && rm -- "$conf_fn"
else
CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf --show-config-value admin_socket)`
CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)`
# -k is implied... (doesn't make sense otherwise)
overwrite_conf=0
fi
Expand Down

0 comments on commit f22a901

Please sign in to comment.