From: Sage Weil Date: Fri, 19 Apr 2013 20:05:43 +0000 (-0700) Subject: init-ceph: do not stop start on first failure X-Git-Tag: v0.61~141 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d395aa521e8a4b295ed2b08dd7cfb7d9f995fcf7;p=ceph.git init-ceph: do not stop start on first failure When starting we often loop over many daemon instances. Currently we stop on the first error and do not try to start other daemons. Instead, try them all, but return a failure if anything did not start. Fixes: #2545 Signed-off-by: Sage Weil Reviewed-by: Gary Lowell --- diff --git a/src/ceph_common.sh b/src/ceph_common.sh index 7e8183cde995..188a5d537502 100644 --- a/src/ceph_common.sh +++ b/src/ceph_common.sh @@ -99,6 +99,24 @@ do_cmd() { fi } +do_cmd_okfail() { + ERR=0 + if [ -z "$ssh" ]; then + [ $verbose -eq 1 ] && echo "--- $host# $1" + ulimit -c unlimited + whoami=`whoami` + if [ "$whoami" = "$user" ] || [ -z "$user" ]; then + bash -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && ERR=1 && return 1; } + else + sudo su $user -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && ERR=1 && return 1; } + fi + else + [ $verbose -eq 1 ] && echo "--- $ssh $2 \"if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi; cd $sshdir ; ulimit -c unlimited ; $1\"" + $ssh $2 "if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi; cd $sshdir ; ulimit -c unlimited ; $1" || { [ -z "$3" ] && echo "failed: '$ssh $1'" && ERR=1 && return 1; } + fi + return 0 +} + do_root_cmd() { if [ -z "$ssh" ]; then [ $verbose -eq 1 ] && echo "--- $host# $1" diff --git a/src/init-ceph.in b/src/init-ceph.in index 4c1646280c46..c2148822b6cf 100644 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -320,7 +320,10 @@ for name in $what; do get_conf pre_start "" "pre start command" get_conf post_start "" "post start command" [ -n "$pre_start" ] && do_cmd "$pre_start" - do_cmd "$cmd" $runarg + do_cmd_okfail "$cmd" $runarg + if [ "$ERR" != "0" ]; then + EXIT_STATUS=$ERR + fi if [ "$type" = "mon" ]; then # this will only work if we are using default paths