From e8855007568af933b62e35622b456e1a8bfd9452 Mon Sep 17 00:00:00 2001 From: songbaisen Date: Mon, 16 Jan 2017 11:27:07 +0800 Subject: [PATCH] ceph: when osd_location_hook does not exist, we should exit error. 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 --- src/crush/CrushLocation.cc | 6 ++++++ src/init-ceph.in | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/crush/CrushLocation.cc b/src/crush/CrushLocation.cc index 74f663274ab31..c7e78f1caa564 100644 --- a/src/crush/CrushLocation.cc +++ b/src/crush/CrushLocation.cc @@ -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(), diff --git a/src/init-ceph.in b/src/init-ceph.in index 54061a8a2a893..07f49c9458f9b 100755 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -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) }')" -- 2.39.5