hydra-evaluator: Add some debug code

This commit is contained in:
Eelco Dolstra 2015-04-09 17:35:04 +02:00
parent a2dc92d871
commit 63306aaf5a
2 changed files with 31 additions and 7 deletions

View file

@ -330,10 +330,20 @@ sub evalJobs {
my $nixExprFullPath = $nixExprInput->{storePath} . "/" . $nixExprPath;
my $evaluator = ($exprType eq "guile") ? "hydra-eval-guile-jobs" : "hydra-eval-jobs";
print STDERR "evaluator ${evaluator}\n";
(my $res, my $jobsJSON, my $stderr) = captureStdoutStderr(10800,
$evaluator, $nixExprFullPath, "--gc-roots-dir", getGCRootsDir, "-j", 1, inputsToArgs($inputInfo, $exprType));
my @cmd = ($evaluator, $nixExprFullPath, "--gc-roots-dir", getGCRootsDir, "-j", 1, inputsToArgs($inputInfo, $exprType));
if (defined $ENV{'HYDRA_DEBUG'}) {
sub escape {
my $s = $_;
$s =~ s/'/'\\''/g;
return "'" . $s . "'";
}
my @escaped = map escape, @cmd;
print STDERR "evaluator: @escaped\n";
}
(my $res, my $jobsJSON, my $stderr) = captureStdoutStderr(10800, @cmd);
die "$evaluator returned " . ($res & 127 ? "signal $res" : "exit code " . ($res >> 8))
. ":\n" . ($stderr ? $stderr : "(no output)\n")
if $res;

View file

@ -25,6 +25,7 @@ my $plugins = [Hydra::Plugin->instantiate(db => $db, config => $config)];
# Don't check a jobset more than once every five minutes.
my $minCheckInterval = 5 * 60;
my $dryRun = defined $ENV{'HYDRA_DRY_RUN'};
sub fetchInputs {
@ -112,7 +113,7 @@ sub checkJobsetWrapped {
my $msg = $@;
print STDERR $msg;
txn_do($db, sub {
$jobset->update({ lastcheckedtime => time, fetcherrormsg => $msg });
$jobset->update({ lastcheckedtime => time, fetcherrormsg => $msg }) if !$dryRun;
});
return;
}
@ -124,7 +125,7 @@ sub checkJobsetWrapped {
my @args = ($jobset->nixexprinput, $jobset->nixexprpath, inputsToArgs($inputInfo, $exprType));
my $argsHash = sha256_hex("@args");
my $prevEval = getPrevJobsetEval($db, $jobset, 0);
if (defined $prevEval && $prevEval->hash eq $argsHash) {
if (defined $prevEval && $prevEval->hash eq $argsHash && !$dryRun) {
print STDERR " jobset is unchanged, skipping\n";
txn_do($db, sub {
$jobset->update({ lastcheckedtime => time, fetcherrormsg => undef });
@ -137,6 +138,18 @@ sub checkJobsetWrapped {
my ($jobs, $nixExprInput) = evalJobs($inputInfo, $exprType, $jobset->nixexprinput, $jobset->nixexprpath);
my $evalStop = time;
if ($dryRun) {
foreach my $name (keys %{$jobs}) {
my $job = $jobs->{$name};
if (defined $job->{drvPath}) {
print STDERR "good job $name: $job->{drvPath}\n";
} else {
print STDERR "failed job $name: $job->{error}\n";
}
}
return;
}
$jobs->{$_}->{jobName} = $_ for keys %{$jobs};
my $jobOutPathMap = {};
@ -268,7 +281,7 @@ sub checkJobset {
txn_do($db, sub {
$jobset->update({lastcheckedtime => time});
setJobsetError($jobset, $msg);
});
}) if !$dryRun;
$failed = 1;
}
@ -280,8 +293,9 @@ sub checkJobset {
my $new = $jobset->get_from_storage();
$jobset->update({ triggertime => undef })
if $new->triggertime == $triggerTime;
});
}) if !$dryRun;
}
return $failed;
}