From: Loic Dachary Date: Fri, 13 Jun 2014 12:41:39 +0000 (+0200) Subject: tests: prevent kill race condition X-Git-Tag: v0.80.8~5^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=754363f4563e7dbda1ef23fadc8d6ef1a3fdd0af;p=ceph.git tests: prevent kill race condition When trying to kill a daemon, keep its pid in a variable instead of retrieving it from the pidfile multiple times. It prevents the following race condition: * try to kill ceph-mon * ceph-mon is in the process of dying and removed its pidfile * try to kill ceph-mon fails because the pidfile is not found * another ceph-mon is spawned and fails to bind the port because the previous ceph-mon is still holding it Signed-off-by: Loic Dachary (cherry picked from commit a1c13c57ba20fc329d943ea57523913e11067dc7) --- diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh index 767a9695cf0..93e5f3bc015 100755 --- a/src/test/ceph-disk.sh +++ b/src/test/ceph-disk.sh @@ -73,8 +73,9 @@ function run_mon() { function kill_daemons() { for pidfile in $(find $DIR | grep pidfile) ; do + pid=$(cat $pidfile) for try in 0 1 1 1 2 3 ; do - kill $(cat $pidfile) || break + kill $pid || break sleep $try done done diff --git a/src/test/mon/mkfs.sh b/src/test/mon/mkfs.sh index 035bb596e15..1910d137b9e 100755 --- a/src/test/mon/mkfs.sh +++ b/src/test/mon/mkfs.sh @@ -66,8 +66,9 @@ function mon_run() { function kill_daemons() { for pidfile in $(find $DIR -name pidfile) ; do + pid=$(cat $pidfile) for try in 0 1 1 1 2 3 ; do - kill $(cat $pidfile) || break + kill $pid || break sleep $try done done diff --git a/src/test/mon/mon-test-helpers.sh b/src/test/mon/mon-test-helpers.sh index d228569edd4..052b1ca3fbd 100644 --- a/src/test/mon/mon-test-helpers.sh +++ b/src/test/mon/mon-test-helpers.sh @@ -59,8 +59,9 @@ function run_mon() { function kill_daemons() { local dir=$1 for pidfile in $(find $dir | grep pidfile) ; do + pid=$(cat $pidfile) for try in 0 1 1 1 2 3 ; do - kill -9 $(cat $pidfile 2> /dev/null) 2> /dev/null || break + kill -9 $pid 2> /dev/null || break sleep $try done done