From 59a26360c75f1cf5fe65fce5e3703df0b6645140 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Apr 2012 17:22:45 -0400 Subject: [PATCH] Support mandatory system features in the build hook Mandatory features are features that MUST be present in a derivation's requiredSystemFeatures attribute. One application is performance testing, where we have a dedicated machine to run performance tests (and nothing else). Then we would add the label "perf" to the machine's mandatory features and to the performance testing derivations. --- doc/manual/build-farm.xml | 17 ++++++++++++++--- scripts/build-remote.pl.in | 12 ++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/manual/build-farm.xml b/doc/manual/build-farm.xml index f2d4a477e..2e0d86b89 100644 --- a/doc/manual/build-farm.xml +++ b/doc/manual/build-farm.xml @@ -31,6 +31,7 @@ variable. nix@mcflurry.labs.cs.uu.nl powerpc-darwin /home/nix/.ssh/id_quarterpounder_auto 2 nix@scratchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 1 kvm nix@itchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 2 +nix@poochie.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 2 kvm perf @@ -73,11 +74,12 @@ bits of information: the machine. If there are multiple machines of the right type, Nix will prefer the fastest, taking load into account. - A comma-separated list of - features. If a derivation has the + A comma-separated list of supported + features. If a derivation has the requiredSystemFeatures attribute, then build-remote.pl will only perform the - derivation on a machine that has the specified features. For instance, the attribute + derivation on a machine that has the specified features. For + instance, the attribute requiredSystemFeatures = [ "kvm" ]; @@ -87,6 +89,15 @@ requiredSystemFeatures = [ "kvm" ]; kvm feature (i.e., scratchy in the example above). + A comma-separated list of mandatory + features. A machine will only be used to build a + derivation if all of the machine’s mandatory features appear in the + derivation’s requiredSystemFeatures attribute. + Thus, in the example, the machine poochie will + only do derivations that have + requiredSystemFeatures set to ["kvm" + "perf"] or ["perf"]. + You should also set up the environment variable diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index da5561cd2..e54386d42 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -70,13 +70,16 @@ if (defined $conf && -e $conf) { s/\#.*$//g; next if /^\s*$/; my @tokens = split /\s/, $_; + my @supportedFeatures = split(/,/, $tokens[5] || ""); + my @mandatoryFeatures = split(/,/, $tokens[6] || ""); push @machines, { hostName => $tokens[0] , systemTypes => [ split(/,/, $tokens[1]) ] , sshKeys => $tokens[2] , maxJobs => int($tokens[3]) , speedFactor => 1.0 * (defined $tokens[4] ? int($tokens[4]) : 1) - , features => [ split(/,/, $tokens[5] || "") ] + , supportedFeatures => [ @supportedFeatures, @mandatoryFeatures ] + , mandatoryFeatures => [ @mandatoryFeatures ] , enabled => 1 }; } @@ -90,8 +93,7 @@ my ($drvPath, $hostName, $slotLock); REQ: while (1) { $_ = || exit 0; - my ($amWilling, $neededSystem); - ($amWilling, $neededSystem, $drvPath, $requiredFeatures) = split; + (my $amWilling, my $neededSystem, $drvPath, my $requiredFeatures) = split; my @requiredFeatures = split /,/, $requiredFeatures; my $canBuildLocally = $amWilling && ($localSystem eq $neededSystem); @@ -117,7 +119,9 @@ REQ: while (1) { LOOP: foreach my $cur (@machines) { if ($cur->{enabled} && (grep { $neededSystem eq $_ } @{$cur->{systemTypes}}) - && all(map { my $f = $_; 0 != grep { $f eq $_ } @{$cur->{features}} } @requiredFeatures)) + && all(map { my $f = $_; 0 != grep { $f eq $_ } @{$cur->{supportedFeatures}} } (@requiredFeatures, @mandatoryFeatures)) + && all(map { my $f = $_; 0 != grep { $f eq $_ } @requiredFeatures } @{$cur->{mandatoryFeatures}}) + ) { $rightType = 1;