From a74251af2b64fed879a0f933d450149c3a1d0ef4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 2 Mar 2016 15:08:53 +0100 Subject: [PATCH] Disable channels on binary cached based Hydra instances --- src/lib/Hydra/Controller/Build.pm | 2 ++ src/lib/Hydra/Controller/Job.pm | 1 + src/lib/Hydra/Controller/Jobset.pm | 1 + src/lib/Hydra/Controller/JobsetEval.pm | 1 + src/lib/Hydra/Controller/Project.pm | 1 + src/lib/Hydra/Controller/Root.pm | 1 + src/lib/Hydra/Helper/CatalystUtils.pm | 8 ++++++++ 7 files changed, 15 insertions(+) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 37d265f0..2571d11b 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -439,6 +439,8 @@ sub runtime_deps : Chained('buildChain') PathPart('runtime-deps') { my $build = $c->stash->{build}; my @outPaths = map { $_->path } $build->buildoutputs->all; + requireLocalStore($c); + error($c, "Build outputs no longer available.") unless all { isValidPath($_) } @outPaths; my $done = {}; diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index 475eca37..73a3dcbd 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -130,6 +130,7 @@ sub metric : Chained('job') PathPart('metric') Args(1) { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('job') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; + requireLocalStore($c); $c->stash->{allBuilds} = $c->stash->{job}->builds; $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForJob') ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name, $c->stash->{job}->name]}); diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index f2b801f1..d6dda604 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -148,6 +148,7 @@ sub channels_tab : Chained('jobsetChain') PathPart('channels-tab') Args(0) { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('jobsetChain') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; + requireLocalStore($c); $c->stash->{allBuilds} = $c->stash->{jobset}->builds; $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForJobset') ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]}); diff --git a/src/lib/Hydra/Controller/JobsetEval.pm b/src/lib/Hydra/Controller/JobsetEval.pm index 8228ed90..53520322 100644 --- a/src/lib/Hydra/Controller/JobsetEval.pm +++ b/src/lib/Hydra/Controller/JobsetEval.pm @@ -222,6 +222,7 @@ sub bump : Chained('evalChain') PathPart('bump') Args(0) { # Hydra::Base::Controller::NixChannel needs this. sub nix : Chained('evalChain') PathPart('channel') CaptureArgs(0) { my ($self, $c) = @_; + requireLocalStore($c); $c->stash->{channelName} = $c->stash->{project}->name . "-" . $c->stash->{jobset}->name . "-latest"; $c->stash->{channelBuilds} = $c->stash->{eval}->builds ->search_literal("exists (select 1 from buildproducts where build = build.id and type = 'nix-build')") diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 4cd577b1..64f5e011 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -161,6 +161,7 @@ sub updateProject { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('projectChain') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; + requireLocalStore($c); $c->stash->{allBuilds} = $c->stash->{project}->builds; $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForProject') ->search({}, {bind => [$c->stash->{project}->name]}); diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 8827d4f0..b03212bc 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -166,6 +166,7 @@ sub machines :Local Args(0) { # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('/') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; + requireLocalStore($c); $c->stash->{allBuilds} = $c->model('DB::Builds'); $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceeded'); $c->stash->{channelBaseName} = "everything"; diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 43e1cc8b..6f05e8e5 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -25,6 +25,7 @@ our @EXPORT = qw( getResponsibleAuthors setCacheHeaders approxTableSize + requireLocalStore ); @@ -343,4 +344,11 @@ sub approxTableSize { } +sub requireLocalStore { + my ($c) = @_; + notFound($c, "Nix channels are not supported by this Hydra server.") + if ($c->config->{store_mode} // "direct") ne "direct"; +} + + 1;