Skip to content

Commit

Permalink
Show whether a job still exists
Browse files Browse the repository at this point in the history
In the dashboard and on the job page, indicate whether the job appears
in the latest jobset eval. That way, the user gets some indication if
a job has accidentally disappeared (e.g. due to an evaluation error).
  • Loading branch information
edolstra committed Apr 8, 2014
1 parent 4471cae commit be63c50
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/lib/Hydra/View/TT.pm
Expand Up @@ -8,7 +8,7 @@ __PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
PRE_CHOMP => 1,
POST_CHOMP => 1,
expose_methods => [qw/buildLogExists buildStepLogExists/]);
expose_methods => [qw/buildLogExists buildStepLogExists jobExists/]);

sub buildLogExists {
my ($self, $c, $build) = @_;
Expand All @@ -22,4 +22,15 @@ sub buildStepLogExists {
return defined findLog($c, $step->drvpath, @outPaths);
}

# Check whether the given job is a member of the most recent jobset
# evaluation.
sub jobExists {
my ($self, $c, $job) = @_;
my $latestEval = $job->jobset->jobsetevals->search(
{ hasnewbuilds => 1},
{ rows => 1, order_by => ["id desc"] })->single;
return 0 if !defined $latestEval; # can't happen
return scalar($latestEval->builds->search({ job => $job->name })) != 0;
}

1;
2 changes: 1 addition & 1 deletion src/root/dashboard.tt
Expand Up @@ -22,7 +22,7 @@
<tdata>
[% FOREACH j IN starredJobs %]
<tr>
<td>[% INCLUDE renderFullJobName project=j.job.get_column('project') jobset=j.job.get_column('jobset') job=j.job.name %]</td>
<td><span class="[% IF !jobExists(j.job) %]disabled-job[% END %]">[% INCLUDE renderFullJobName project=j.job.get_column('project') jobset=j.job.get_column('jobset') job=j.job.name %]</span></td>
[% FOREACH b IN j.builds %]
<td><a href="[% c.uri_for('/build' b.id) %]">[% INCLUDE renderBuildStatusIcon size=16 build=b %]</a></td>
[% END %]
Expand Down
7 changes: 7 additions & 0 deletions src/root/job.tt
Expand Up @@ -5,6 +5,13 @@
[% PROCESS common.tt %]
[% hideProjectName=1 hideJobsetName=1 hideJobName=1 %]

[% IF !jobExists(job) %]
<div class="alert alert-warning">This job is not a member of the <a
href="[%c.uri_for('/jobset' project.name jobset.name
'evals')%]">latest evaluation</a> of its jobset. This means it was
removed or had an evaluation error.</div>
[% END %]

<ul class="nav nav-tabs">
<li class="active"><a href="#tabs-status" data-toggle="tab">Status</a></li>
[% IF constituentJobs.size > 0 %]
Expand Down

0 comments on commit be63c50

Please sign in to comment.