From d764c135ce6f0331d78f98f8ff4fe1a85810d8db Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 4 Mar 2013 17:44:19 -0500 Subject: [PATCH] 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. --- src/script/hydra-queue-runner | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/script/hydra-queue-runner b/src/script/hydra-queue-runner index dbf0987f..f0d8b663 100755 --- a/src/script/hydra-queue-runner +++ b/src/script/hydra-queue-runner @@ -73,6 +73,16 @@ sub checkBuilds { 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 { # Get the system types for the runnable builds. @@ -89,10 +99,7 @@ sub checkBuilds { my $nrActive = $db->resultset('Builds')->search( {finished => 0, busy => 1, system => $system->system})->count; - # How many extra builds can we start? - (my $systemTypeInfo) = $db->resultset('SystemTypes')->search({system => $system->system}); - my $maxConcurrent = defined $systemTypeInfo ? $systemTypeInfo->maxconcurrent : 2; - my $extraAllowed = $maxConcurrent - $nrActive; + my $extraAllowed = $maxConcurrent{$system} - $nrActive; $extraAllowed = 0 if $extraAllowed < 0; # Select the highest-priority builds to start. @@ -102,7 +109,7 @@ sub checkBuilds { rows => $extraAllowed }); print "system type `", $system->system, - "': $nrActive active, $maxConcurrent allowed, ", + "': $nrActive active, $maxConcurrent{$system} allowed, ", "starting ", scalar(@builds), " builds\n"; foreach my $build (@builds) {