]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: when osd_location_hook does not exist, we should exit error. 12961/head
authorsongbaisen <song.baisen@zte.com.cn>
Mon, 16 Jan 2017 03:27:07 +0000 (11:27 +0800)
committersongbaisen <song.baisen@zte.com.cn>
Tue, 17 Jan 2017 11:47:48 +0000 (19:47 +0800)
    If the user define "osd crush location hook" in ceph.conf, but the
    osd_location_hook tool does not exist,we should exit error.

Signed-off-by:song baisen <song.baisen@zte.com.cn>

src/crush/CrushLocation.cc
src/init-ceph.in

index 74f663274ab31e25aa84efe9dbf1aa47278f28fc..c7e78f1caa564b112216c3aef42f156fd231b0b2 100644 (file)
@@ -42,6 +42,12 @@ int CrushLocation::update_from_hook()
 {
   if (cct->_conf->crush_location_hook.length() == 0)
     return 0;
+  if (0 != access(cct->_conf->crush_location_hook.c_str(), R_OK)) {
+    lderr(cct) << "the user define crush location hook: " << cct->_conf->crush_location_hook
+               << " may not exist or can not access it" << dendl;
+    return errno;
+  }
 
   SubProcessTimed hook(
     cct->_conf->crush_location_hook.c_str(),
index 54061a8a2a893ccf7e58e14dbff0195d3b30214d..07f49c9458f9b3747d5299c060f11d64888fcced 100755 (executable)
@@ -408,6 +408,10 @@ for name in $what; do
                case "${update_crush:-1}" in 1|[Tt][Rr][Uu][Ee])
                    # update location in crush
                    get_conf osd_location_hook "$BINDIR/ceph-crush-location" "osd crush location hook"
+                   if [ ! -e "$osd_location_hook" ]; then
+                       EXIT_STATUS=2
+                       continue
+                   fi
                    osd_location=`$osd_location_hook --cluster $cluster --id $id --type osd`
                    get_conf osd_weight "" "osd crush initial weight"
                    defaultweight="$(df -P -k $osd_data/. | tail -1 | awk '{ print sprintf("%.4f",$2/1073741824) }')"