From 92d8d6baa5334466844fdc9aef7f8cd40a51d679 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 13 Aug 2019 17:42:19 +0200 Subject: [PATCH] Avoid fetching Projects/Jobsets just to get the name column In particular, doing a 'select * from Jobsets where ...' must be avoided, because the 'errormsg' column can be very big. --- src/lib/Hydra/Controller/API.pm | 6 +++--- src/lib/Hydra/Controller/JobsetEval.pm | 2 +- src/lib/Hydra/Helper/CatalystUtils.pm | 14 +++++++------- src/lib/Hydra/Plugin/EmailNotification.pm | 8 ++++---- src/lib/Hydra/Plugin/GitlabStatus.pm | 2 +- src/lib/Hydra/Plugin/HipChatNotification.pm | 2 +- src/lib/Hydra/Plugin/InfluxDBNotification.pm | 8 ++++---- src/lib/Hydra/Plugin/SlackNotification.pm | 2 +- src/script/hydra-eval-jobset | 6 +++--- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lib/Hydra/Controller/API.pm b/src/lib/Hydra/Controller/API.pm index dfde7b30..45cecfea 100644 --- a/src/lib/Hydra/Controller/API.pm +++ b/src/lib/Hydra/Controller/API.pm @@ -76,7 +76,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) { sub jobsetToHash { my ($jobset) = @_; return { - project => $jobset->project->name, + project => $jobset->get_column('project'), name => $jobset->name, nrscheduled => $jobset->get_column("nrscheduled"), nrsucceeded => $jobset->get_column("nrsucceeded"), @@ -206,12 +206,12 @@ sub scmdiff : Path('/api/scmdiff') Args(0) { sub triggerJobset { my ($self, $c, $jobset, $force) = @_; - print STDERR "triggering jobset ", $jobset->project->name . ":" . $jobset->name, "\n"; + print STDERR "triggering jobset ", $jobset->get_column('project') . ":" . $jobset->name, "\n"; txn_do($c->model('DB')->schema, sub { $jobset->update({ triggertime => time }); $jobset->update({ forceeval => 1 }) if $force; }); - push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->project->name . ":" . $jobset->name; + push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->get_column('project') . ":" . $jobset->name; } diff --git a/src/lib/Hydra/Controller/JobsetEval.pm b/src/lib/Hydra/Controller/JobsetEval.pm index 12af29c2..77a4385f 100644 --- a/src/lib/Hydra/Controller/JobsetEval.pm +++ b/src/lib/Hydra/Controller/JobsetEval.pm @@ -142,7 +142,7 @@ sub release : Chained('evalChain') PathPart('release') Args(0) { $releaseName ||= $_->releasename foreach @builds; # If no release name has been defined by any of the builds, compose one of the project name and evaluation id - $releaseName = $eval->project->name."-".$eval->id unless defined $releaseName; + $releaseName = $eval->get_column('project') . "-" . $eval->id unless defined $releaseName; my $release; diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index a6401676..b9019638 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -60,9 +60,9 @@ sub getNextBuild { (my $nextBuild) = $c->model('DB::Builds')->search( { finished => 1 , system => $build->system - , project => $build->project->name - , jobset => $build->jobset->name - , job => $build->job->name + , project => $build->get_column('project') + , jobset => $build->get_column('jobset') + , job => $build->get_column('job') , 'me.id' => { '>' => $build->id } }, {rows => 1, order_by => "me.id ASC"}); @@ -77,9 +77,9 @@ sub getPreviousSuccessfulBuild { (my $prevBuild) = $c->model('DB::Builds')->search( { finished => 1 , system => $build->system - , project => $build->project->name - , jobset => $build->jobset->name - , job => $build->job->name + , project => $build->get_column('project') + , jobset => $build->get_column('jobset') + , job => $build->get_column('job') , buildstatus => 0 , 'me.id' => { '<' => $build->id } }, {rows => 1, order_by => "me.id DESC"}); @@ -289,7 +289,7 @@ sub parseJobsetName { sub showJobName { my ($build) = @_; - return $build->project->name . ":" . $build->jobset->name . ":" . $build->job->name; + return $build->get_column('project') . ":" . $build->get_column('jobset') . ":" . $build->get_column('job'); } diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 9c2639d1..33935069 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -100,7 +100,7 @@ sub buildFinished { , dependents => [grep { $_->id != $build->id } @builds] , baseurl => getBaseUrl($self->{config}) , showJobName => \&showJobName, showStatus => \&showStatus - , showSystem => index($build->job->name, $build->system) == -1 + , showSystem => index($build->get_column('job'), $build->system) == -1 , nrCommits => $nrCommits , authorList => $authorList }; @@ -119,9 +119,9 @@ sub buildFinished { sendEmail( $self->{config}, $to, $subject, $body, - [ 'X-Hydra-Project' => $build->project->name, - , 'X-Hydra-Jobset' => $build->jobset->name, - , 'X-Hydra-Job' => $build->job->name, + [ 'X-Hydra-Project' => $build->get_column('project'), + , 'X-Hydra-Jobset' => $build->get_column('jobset'), + , 'X-Hydra-Job' => $build->get_column('job'), , 'X-Hydra-System' => $build->system ]); } diff --git a/src/lib/Hydra/Plugin/GitlabStatus.pm b/src/lib/Hydra/Plugin/GitlabStatus.pm index 55c01472..0c9c36ba 100644 --- a/src/lib/Hydra/Plugin/GitlabStatus.pm +++ b/src/lib/Hydra/Plugin/GitlabStatus.pm @@ -55,7 +55,7 @@ sub common { state => $state, target_url => "$baseurl/build/" . $b->id, description => "Hydra build #" . $b->id . " of $jobName", - name => "Hydra " . $b->job->name, + name => "Hydra " . $b->get_column('job'), }); while (my $eval = $evals->next) { my $gitlabstatusInput = $eval->jobsetevalinputs->find({ name => "gitlab_status_repo" }); diff --git a/src/lib/Hydra/Plugin/HipChatNotification.pm b/src/lib/Hydra/Plugin/HipChatNotification.pm index 7df39593..e4d1b74f 100644 --- a/src/lib/Hydra/Plugin/HipChatNotification.pm +++ b/src/lib/Hydra/Plugin/HipChatNotification.pm @@ -59,7 +59,7 @@ sub buildFinished { my $msg = ""; $msg .= " "; - $msg .= "Job ${\showJobName($build)}"; + $msg .= "Job get_column('jobset')}/${\$build->get_column('job')}'>${\showJobName($build)}"; $msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0; $msg .= ": " . showStatus($build) . ""; diff --git a/src/lib/Hydra/Plugin/InfluxDBNotification.pm b/src/lib/Hydra/Plugin/InfluxDBNotification.pm index 89732e3b..3b653201 100644 --- a/src/lib/Hydra/Plugin/InfluxDBNotification.pm +++ b/src/lib/Hydra/Plugin/InfluxDBNotification.pm @@ -104,10 +104,10 @@ sub buildFinished { my $tagSet = { status => toBuildStatusClass($b->buildstatus), result => toBuildStatusDetailed($b->buildstatus), - project => $b->project->name, - jobset => $b->jobset->name, - repo => ($b->jobset->name =~ /^(.*)\.pr-/) ? $1 : $b->jobset->name, - job => $b->job->name, + project => $b->get_column('project'), + jobset => $b->get_column('jobset'), + repo => ($b->get_column('jobset') =~ /^(.*)\.pr-/) ? $1 : $b->get_column('jobset'), + job => $b->get_column('job'), system => $b->system, cached => $b->iscachedbuild ? "true" : "false", }; diff --git a/src/lib/Hydra/Plugin/SlackNotification.pm b/src/lib/Hydra/Plugin/SlackNotification.pm index 6ee249c8..96933c51 100644 --- a/src/lib/Hydra/Plugin/SlackNotification.pm +++ b/src/lib/Hydra/Plugin/SlackNotification.pm @@ -81,7 +81,7 @@ sub buildFinished { "danger"; my $text = ""; - $text .= "Job <$baseurl/job/${\$build->project->name}/${\$build->jobset->name}/${\$build->job->name}|${\showJobName($build)}>"; + $text .= "Job <$baseurl/job/${\$build->get_column('project')}/${\$build->get_column('jobset')}/${\$build->get_column('job')}|${\showJobName($build)}>"; $text .= " (and ${\scalar @deps} others)" if scalar @deps > 0; $text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build); diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index 5b31c735..2049fe24 100755 --- a/src/script/hydra-eval-jobset +++ b/src/script/hydra-eval-jobset @@ -438,7 +438,7 @@ sub checkBuild { # semantically unnecessary (because they're implied by # the eval), but they give a factor 1000 speedup on # the Nixpkgs jobset with PostgreSQL. - { project => $jobset->project->name, jobset => $jobset->name, job => $jobName, + { project => $jobset->get_column('project'), jobset => $jobset->name, job => $jobName, name => $firstOutputName, path => $firstOutputPath }, { rows => 1, columns => ['id'], join => ['buildoutputs'] }); if (defined $prevBuild) { @@ -489,7 +489,7 @@ sub checkBuild { $buildMap->{$build->id} = { id => $build->id, jobName => $jobName, new => 1, drvPath => $drvPath }; $$jobOutPathMap{$jobName . "\t" . $firstOutputPath} = $build->id; - print STDERR "added build ${\$build->id} (${\$jobset->project->name}:${\$jobset->name}:$jobName)\n"; + print STDERR "added build ${\$build->id} (${\$jobset->get_column('project')}:${\$jobset->name}:$jobName)\n"; }); return $build; @@ -531,7 +531,7 @@ sub sendJobsetErrorNotification() { return if $jobset->project->owner->emailonerror == 0; return if $errorMsg eq ""; - my $projectName = $jobset->project->name; + my $projectName = $jobset->get_column('project'); my $jobsetName = $jobset->name; my $body = "Hi,\n" . "\n"