Respect SystemTypes if defined

This commit is contained in:
Eelco Dolstra 2013-03-05 18:01:44 +01:00
parent fcd511c4de
commit 6d131719be

View file

@ -75,7 +75,7 @@ sub checkBuilds {
my $machines = getMachines; my $machines = getMachines;
my %maxConcurrent = (); my %maxConcurrent;
foreach my $machineName (keys %{$machines}) { foreach my $machineName (keys %{$machines}) {
foreach my $system (${$machines}{$machineName}{'systemTypes'}) { foreach my $system (${$machines}{$machineName}{'systemTypes'}) {
@ -99,7 +99,10 @@ 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;
my $extraAllowed = $maxConcurrent{$system} - $nrActive; (my $systemTypeInfo) = $db->resultset('SystemTypes')->search({system => $system->system});
my $max = defined $systemTypeInfo ? $systemTypeInfo->maxconcurrent : $maxConcurrent{$system} // 2;
my $extraAllowed = $max - $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.
@ -109,7 +112,7 @@ sub checkBuilds {
rows => $extraAllowed }); rows => $extraAllowed });
print "system type `", $system->system, print "system type `", $system->system,
"': $nrActive active, $maxConcurrent{$system} allowed, ", "': $nrActive active, $max allowed, ",
"starting ", scalar(@builds), " builds\n"; "starting ", scalar(@builds), " builds\n";
foreach my $build (@builds) { foreach my $build (@builds) {