forked from lix-project/hydra
Send notifications when evaluations start/finish/fail
* 'eval_started' has the format '<tmpId>\t<project>\t<jobset>'. * 'eval_failed' has the format '<tmpId>'. (The cause of the error can be found in the database.) * 'eval_added' has the format '<tmpId>:<evalId>'.
This commit is contained in:
parent
7114d2aceb
commit
976d88d675
|
@ -568,7 +568,7 @@ sub permute {
|
||||||
|
|
||||||
|
|
||||||
sub checkJobsetWrapped {
|
sub checkJobsetWrapped {
|
||||||
my ($jobset) = @_;
|
my ($jobset, $tmpId) = @_;
|
||||||
my $project = $jobset->project;
|
my $project = $jobset->project;
|
||||||
my $jobsetsJobset = length($project->declfile) && $jobset->name eq ".jobsets";
|
my $jobsetsJobset = length($project->declfile) && $jobset->name eq ".jobsets";
|
||||||
my $inputInfo = {};
|
my $inputInfo = {};
|
||||||
|
@ -607,6 +607,7 @@ sub checkJobsetWrapped {
|
||||||
print STDERR $fetchError;
|
print STDERR $fetchError;
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
$jobset->update({ lastcheckedtime => time, fetcherrormsg => $fetchError }) if !$dryRun;
|
$jobset->update({ lastcheckedtime => time, fetcherrormsg => $fetchError }) if !$dryRun;
|
||||||
|
$db->storage->dbh->do("notify eval_failed, ?", undef, join('\t', $tmpId));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -622,6 +623,7 @@ sub checkJobsetWrapped {
|
||||||
Net::Statsd::increment("hydra.evaluator.unchanged_checkouts");
|
Net::Statsd::increment("hydra.evaluator.unchanged_checkouts");
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
$jobset->update({ lastcheckedtime => time, fetcherrormsg => undef });
|
$jobset->update({ lastcheckedtime => time, fetcherrormsg => undef });
|
||||||
|
$db->storage->dbh->do("notify eval_cached, ?", undef, join('\t', $tmpId));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -690,6 +692,9 @@ sub checkJobsetWrapped {
|
||||||
, nrbuilds => $jobsetChanged ? scalar(keys %buildMap) : undef
|
, nrbuilds => $jobsetChanged ? scalar(keys %buildMap) : undef
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$db->storage->dbh->do("notify eval_added, ?", undef,
|
||||||
|
join('\t', $tmpId, $ev->id));
|
||||||
|
|
||||||
if ($jobsetChanged) {
|
if ($jobsetChanged) {
|
||||||
# Create JobsetEvalMembers mappings.
|
# Create JobsetEvalMembers mappings.
|
||||||
while (my ($id, $x) = each %buildMap) {
|
while (my ($id, $x) = each %buildMap) {
|
||||||
|
@ -767,10 +772,6 @@ sub checkJobsetWrapped {
|
||||||
Net::Statsd::increment("hydra.evaluator.evals");
|
Net::Statsd::increment("hydra.evaluator.evals");
|
||||||
Net::Statsd::increment("hydra.evaluator.cached_evals") unless $jobsetChanged;
|
Net::Statsd::increment("hydra.evaluator.cached_evals") unless $jobsetChanged;
|
||||||
|
|
||||||
#while (my ($id, $x) = each %buildMap) {
|
|
||||||
# system("hydra-notify build-queued $id") if $x->{new};
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Store the error messages for jobs that failed to evaluate.
|
# Store the error messages for jobs that failed to evaluate.
|
||||||
my $msg = "";
|
my $msg = "";
|
||||||
foreach my $job (values %{$jobs}) {
|
foreach my $job (values %{$jobs}) {
|
||||||
|
@ -788,8 +789,15 @@ sub checkJobset {
|
||||||
|
|
||||||
my $startTime = clock_gettime(CLOCK_MONOTONIC);
|
my $startTime = clock_gettime(CLOCK_MONOTONIC);
|
||||||
|
|
||||||
|
# Add an ID to eval_* notifications so receivers can correlate
|
||||||
|
# them.
|
||||||
|
my $tmpId = "${startTime}.$$";
|
||||||
|
|
||||||
|
$db->storage->dbh->do("notify eval_started, ?", undef,
|
||||||
|
join('\t', $tmpId, $jobset->get_column('project'), $jobset->name));
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
checkJobsetWrapped($jobset);
|
checkJobsetWrapped($jobset, $tmpId);
|
||||||
};
|
};
|
||||||
my $checkError = $@;
|
my $checkError = $@;
|
||||||
|
|
||||||
|
@ -802,6 +810,7 @@ sub checkJobset {
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
$jobset->update({lastcheckedtime => time});
|
$jobset->update({lastcheckedtime => time});
|
||||||
setJobsetError($jobset, $checkError);
|
setJobsetError($jobset, $checkError);
|
||||||
|
$db->storage->dbh->do("notify eval_failed, ?", undef, join('\t', $tmpId));
|
||||||
}) if !$dryRun;
|
}) if !$dryRun;
|
||||||
$failed = 1;
|
$failed = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue