From: Ian Jackson Date: Tue, 16 May 2017 13:34:25 +0000 (+0100) Subject: ts-hosts-allocate-Executive: Honour hostalloc_maxwait_max X-Git-Tag: openstack-v11~47 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f9aae599d75d1d56206c1a32b1a7dbc06a90fb04;p=people%2Faperard%2Fosstest.git ts-hosts-allocate-Executive: Honour hostalloc_maxwait_max No functional change with existing flights. Signed-off-by: Ian Jackson --- diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive index 0987e2b5..9955cbad 100755 --- a/ts-hosts-allocate-Executive +++ b/ts-hosts-allocate-Executive @@ -56,6 +56,7 @@ if ($ENV{'OSSTEST_NOALLOCATE'}) { } # initialised by setup: +our $alloc_start_time; our $taskid; our %magictaskid; our $fi; @@ -109,6 +110,8 @@ END WHERE type='magic' AND refkey=? END } + + $alloc_start_time = time // die $!; } #---------- prepared sql statements ---------- @@ -748,6 +751,16 @@ sub attempt_allocation { logm("host allocation: successful, reporting to planner."); } else { logm("host allocation: planned start in $best->{Start} seconds."); + my $maxwait = $r{hostalloc_maxwait_max}; + if (defined $maxwait) { + # We quit if: + # * we have been waiting at least $maxwait/2 + # * we estimate it will take at least $maxwait overall + my $wait_sofar = (time // die $!) - $alloc_start_time; + die "timed out: $wait_sofar, $best->{Start}, $maxwait" + if $wait_sofar > $maxwait/2 + && $wait_sofar + $best->{Start} > $maxwait; + } } if ($fake) {