From f3def4a0e5bd3eda5745902f1dd93b3a827bbf89 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 15 Nov 2016 12:33:01 -0800 Subject: [PATCH] test: wait_for_clean() add sleep backoff Reduce size of log on timeout by doing a backoff so that we don't log 3000 loops at 1/10 second sleeps. Signed-off-by: David Zafman --- qa/workunits/ceph-helpers.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/qa/workunits/ceph-helpers.sh b/qa/workunits/ceph-helpers.sh index f441830a142..e1825b72cab 100755 --- a/qa/workunits/ceph-helpers.sh +++ b/qa/workunits/ceph-helpers.sh @@ -1085,8 +1085,14 @@ function wait_for_clean() { local num_active_clean=-1 local cur_active_clean local -i timer=0 + local -i loops=0 + local -i phase=0 local num_pgs=$(get_num_pgs) test $num_pgs != 0 || return 1 + local TENTH_TIMEOUT=($TIMEOUT * 10) + # The first phase 10 times (1 second) second phase an additional 15 times (15 seconds) + local backoff_phases=( 10 15 -1 ) + local sleep_backoff=( .1 1 10) while true ; do # Comparing get_num_active_clean & get_num_pgs is used to determine @@ -1095,16 +1101,21 @@ function wait_for_clean() { cur_active_clean=$(get_num_active_clean) test $cur_active_clean = $num_pgs && break if test $cur_active_clean != $num_active_clean ; then - timer=0 + timer=0 ; loops=0 ; phase=0 num_active_clean=$cur_active_clean elif get_is_making_recovery_progress ; then - timer=0 - elif (( timer >= $(($TIMEOUT * 10)))) ; then + timer=0 ; loops=0 ; phase=0 + elif (( timer >= $TENTH_TIMEOUT)) ; then ceph report return 1 fi - sleep .1 - timer=$(expr $timer + 1) + sleep ${sleep_backoff[$phase]} + timer="$(echo $timer + ${sleep_backoff[$phase]} \* 10 | bc | cut -d. -f1)" + loops=$(expr $loops + 1) + if (( $loops == ${backoff_phases[$phase]} )); then + phase=$(expr $phase + 1) + loop=0 + fi done return 0 } -- 2.39.5