]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: ceph-monstore-update-crush: fail early if mon's running 5052/head
authorJoao Eduardo Luis <joao@suse.de>
Mon, 13 Jul 2015 14:05:50 +0000 (15:05 +0100)
committerKefu Chai <kchai@redhat.com>
Fri, 17 Jul 2015 11:15:44 +0000 (19:15 +0800)
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/tools/ceph-monstore-update-crush.sh

index 3f24a083643202159f1f103f208716903585551a..dc6a6d724a50e876676d70ce2ccc54389f804034 100755 (executable)
@@ -35,7 +35,8 @@ function osdmap_get() {
     local osdmap=`mktemp`
 
     ceph-monstore-tool $store_path get osdmap -- \
-                       $epoch -o $osdmap > /dev/null
+                       $epoch -o $osdmap > /dev/null || return
+
     echo $(osdmaptool --dump xml $osdmap 2> /dev/null | \
            $XMLSTARLET sel -t -m "$query" -v .)
 
@@ -73,6 +74,12 @@ function get_crush()  {
     osdmaptool --export-crush $crush $osdmap_path 2>&1 > /dev/null
 }
 
+function die() {
+    local retval=$?
+    echo "$@" >&2
+    exit $retval
+}
+
 function usage() {
     [ $# -gt 0 ] && echo -e "\n$@"
     cat <<EOF
@@ -127,7 +134,11 @@ function main() {
     local store_path="$1"
     test $store_path || usage "I need the path to mon-store."
 
-    local last_osdmap_epoch=$(osdmap_get $store_path "/osdmap/epoch")
+    # try accessing the store; if it fails, likely means a mon is running
+    local last_osdmap_epoch
+    local max_osd
+    last_osdmap_epoch=$(osdmap_get $store_path "/osdmap/epoch") || \
+        die "error accessing mon store at $store_path"
     # get the max_osd # in last osdmap epoch, crushtool will use it to check
     # the crush maps in previous osdmaps
     max_osd=$(osdmap_get $store_path "/osdmap/max_osd" $last_osdmap_epoch)