From: Loic Dachary Date: Fri, 13 Jun 2014 12:41:39 +0000 (+0200) Subject: tests: prevent kill race condition X-Git-Tag: v0.83~96^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a1c13c57ba20fc329d943ea57523913e11067dc7;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 --- diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh index 35e270266968..3e95bf911a5a 100755 --- a/src/test/ceph-disk.sh +++ b/src/test/ceph-disk.sh @@ -72,8 +72,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 33e3fbafefb0..d24068bdfdd3 100755 --- a/src/test/mon/mkfs.sh +++ b/src/test/mon/mkfs.sh @@ -64,8 +64,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 d228569edd4d..052b1ca3fbdb 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