}
# initialised by setup:
+our $alloc_start_time;
our $taskid;
our %magictaskid;
our $fi;
WHERE type='magic' AND refkey=?
END
}
+
+ $alloc_start_time = time // die $!;
}
#---------- prepared sql statements ----------
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) {