forked from lix-project/hydra
hydra-queue-runner: Use nix.machines instead of the SystemTypes table to determine how many build jobs are allowed per system type.
Note that on machines that support multiple system types, EACH system type gets the full number of build slots, which is almost certainly not what we want.
This commit is contained in:
parent
233e485a55
commit
d764c135ce
|
@ -73,6 +73,16 @@ sub checkBuilds {
|
||||||
|
|
||||||
my @buildsStarted;
|
my @buildsStarted;
|
||||||
|
|
||||||
|
my $machines = getMachines;
|
||||||
|
|
||||||
|
my %maxConcurrent = ();
|
||||||
|
|
||||||
|
foreach my $machineName (keys %{$machines}) {
|
||||||
|
foreach my $system (${$machines}{$machineName}{'systemTypes'}) {
|
||||||
|
$maxConcurrent{$system} = (${$machines}{$machineName}{'maxJobs'} or 0) + ($maxConcurrent{$system} or 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
|
|
||||||
# Get the system types for the runnable builds.
|
# Get the system types for the runnable builds.
|
||||||
|
@ -89,10 +99,7 @@ sub checkBuilds {
|
||||||
my $nrActive = $db->resultset('Builds')->search(
|
my $nrActive = $db->resultset('Builds')->search(
|
||||||
{finished => 0, busy => 1, system => $system->system})->count;
|
{finished => 0, busy => 1, system => $system->system})->count;
|
||||||
|
|
||||||
# How many extra builds can we start?
|
my $extraAllowed = $maxConcurrent{$system} - $nrActive;
|
||||||
(my $systemTypeInfo) = $db->resultset('SystemTypes')->search({system => $system->system});
|
|
||||||
my $maxConcurrent = defined $systemTypeInfo ? $systemTypeInfo->maxconcurrent : 2;
|
|
||||||
my $extraAllowed = $maxConcurrent - $nrActive;
|
|
||||||
$extraAllowed = 0 if $extraAllowed < 0;
|
$extraAllowed = 0 if $extraAllowed < 0;
|
||||||
|
|
||||||
# Select the highest-priority builds to start.
|
# Select the highest-priority builds to start.
|
||||||
|
@ -102,7 +109,7 @@ sub checkBuilds {
|
||||||
rows => $extraAllowed });
|
rows => $extraAllowed });
|
||||||
|
|
||||||
print "system type `", $system->system,
|
print "system type `", $system->system,
|
||||||
"': $nrActive active, $maxConcurrent allowed, ",
|
"': $nrActive active, $maxConcurrent{$system} allowed, ",
|
||||||
"starting ", scalar(@builds), " builds\n";
|
"starting ", scalar(@builds), " builds\n";
|
||||||
|
|
||||||
foreach my $build (@builds) {
|
foreach my $build (@builds) {
|
||||||
|
|
Loading…
Reference in a new issue