Remove the logfile and logSize columns from the database

It's pointless to store these, since Nix knows where the logs are.
Also handle (in fact require) Nix's new log storage scheme.  Also some
cleanups in the build page.
This commit is contained in:
Eelco Dolstra 2013-01-22 22:48:02 +01:00
parent 36c2bf2f52
commit 30e5185acf
30 changed files with 299 additions and 229 deletions

View file

@ -7,6 +7,7 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use Hydra::Helper::AddBuilds;
use File::stat;
use File::Slurp;
use Data::Dump qw(dump);
use Nix::Store;
@ -30,10 +31,6 @@ sub build : Chained('/') PathPart CaptureArgs(1) {
$c->stash->{project} = $c->stash->{build}->project;
}
sub cat_log_command {
my ($path) = @_;
return ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path");
}
sub view_build : Chained('build') PathPart('') Args(0) {
my ($self, $c) = @_;
@ -48,22 +45,14 @@ sub view_build : Chained('build') PathPart('') Args(0) {
$c->stash->{pathHash} = $c->stash->{available} ? queryPathHash($build->outpath) : undef;
if (!$build->finished && $build->busy) {
my $logfile = $build->logfile;
$c->stash->{logtext} = logContents($logfile);
$c->stash->{logtext} = read_file($build->logfile, err_mode => 'quiet') // "";
}
if ($build->finished && $build->iscachedbuild) {
(my $cachedBuildStep) = $c->model('DB::BuildSteps')->search({ outpath => $build->outpath }, {}) ;
(my $cachedBuildStep) = $c->model('DB::BuildSteps')->search({ outpath => $build->outpath }, {});
$c->stash->{cachedBuild} = $cachedBuildStep->build if defined $cachedBuildStep;
}
(my $lastBuildStep) = $build->buildsteps->search({},{order_by => "stepnr DESC", rows => 1});
my $path = defined $lastBuildStep ? $lastBuildStep->logfile : "" ;
if ($build->finished && ($build->buildstatus == 1 || $build->buildstatus == 6) && !($path eq "") && -f $lastBuildStep->logfile) {
my $logtext = logContents($path, 50);
$c->stash->{logtext} = removeAsciiEscapes($logtext);
}
if ($build->finished) {
$c->stash->{prevBuilds} = [$c->model('DB::Builds')->search(
{ project => $c->stash->{project}->name
@ -102,40 +91,34 @@ sub view_nixlog : Chained('build') PathPart('nixlog') {
$c->stash->{step} = $step;
showLog($c, $step->logfile, $mode);
showLog($c, $step->drvpath, $mode);
}
sub view_log : Chained('build') PathPart('log') {
my ($self, $c, $mode) = @_;
error($c, "Build didn't produce a log.") if !defined $c->stash->{build}->logfile;
showLog($c, $c->stash->{build}->logfile, $mode);
showLog($c, $c->stash->{build}->drvpath, $mode);
}
sub showLog {
my ($c, $path, $mode) = @_;
my ($c, $drvPath, $mode) = @_;
my $fallbackpath = -f $path ? $path : "$path.bz2";
my $logPath = getDrvLogPath($drvPath);
notFound($c, "Log file $path no longer exists.") unless -f $fallbackpath;
$path = $fallbackpath;
notFound($c, "The build log of derivation $drvPath is not available.") unless defined $logPath;
if (!$mode) {
# !!! quick hack
my $pipestart = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path") ;
my $pipeline = $pipestart
my $pipeline = "nix-store -l $drvPath"
. " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -"
. " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2";
$c->stash->{template} = 'log.tt';
$c->stash->{logtext} = `$pipeline`;
}
elsif ($mode eq "raw") {
$c->stash->{'plain'} = { data => (scalar logContents($path)) || " " };
$c->stash->{'plain'} = { data => (scalar logContents($drvPath)) || " " };
$c->forward('Hydra::View::Plain');
}
@ -145,12 +128,12 @@ sub showLog {
$c->stash->{url} = $url;
$c->stash->{reload} = !$c->stash->{build}->finished && $c->stash->{build}->busy;
$c->stash->{title} = "";
$c->stash->{contents} = (scalar logContents($path, 50)) || " ";
$c->stash->{contents} = (scalar logContents($drvPath, 50)) || " ";
$c->stash->{template} = 'plain-reload.tt';
}
elsif ($mode eq "tail") {
$c->stash->{'plain'} = { data => (scalar logContents($path, 50)) || " " };
$c->stash->{'plain'} = { data => (scalar logContents($drvPath, 50)) || " " };
$c->forward('Hydra::View::Plain');
}

View file

@ -17,7 +17,7 @@ use File::Temp;
our @ISA = qw(Exporter);
our @EXPORT = qw(
fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr
getReleaseName getBuildLog addBuildProducts restartBuild scmPath
getReleaseName addBuildProducts restartBuild scmPath
getPrevJobsetEval
);
@ -27,16 +27,6 @@ sub scmPath {
}
sub getBuildLog {
my ($drvPath) = @_;
my $logPath = ($ENV{NIX_LOG_DIR} || "/nix/var/log/nix"). "/drvs/" . basename $drvPath;
return $logPath if -e $logPath;
$logPath = "$logPath.bz2";
return $logPath if -e $logPath;
return undef;
}
sub getStorePathHash {
my ($storePath) = @_;
my $hash = `nix-store --query --hash $storePath`
@ -930,7 +920,6 @@ sub checkBuild {
, buildstatus => -f "$outPath/nix-support/failed" ? 6 : 0
, starttime => $time
, stoptime => $time
, logfile => getBuildLog($drvPath)
, errormsg => ""
, releasename => getReleaseName($outPath)
);

View file

@ -14,7 +14,7 @@ our @EXPORT = qw(
getPrimaryBuildsForView
getPrimaryBuildTotal
getViewResult getLatestSuccessfulViewResult
jobsetOverview removeAsciiEscapes logContents);
jobsetOverview removeAsciiEscapes getDrvLogPath logContents);
sub getHydraHome {
@ -238,19 +238,39 @@ sub getLatestSuccessfulViewResult {
return undef;
}
# Return the path of the build log of the given derivation, or undef
# if the log is gone.
sub getDrvLogPath {
my ($drvPath) = @_;
my $base = basename $drvPath;
my $fn =
($ENV{NIX_LOG_DIR} || "/nix/var/log/nix") . "/drvs/"
. substr($base, 0, 2) . "/"
. substr($base, 2);
return $fn if -f $fn;
$fn .= ".bz2";
return $fn if -f $fn;
return undef;
}
sub logContents {
my ($path, $tail) = @_;
my ($drvPath, $tail) = @_;
my $logPath = getDrvLogPath($drvPath);
die unless defined $logPath;
my $cmd;
if ($path =~ /.bz2$/) {
$cmd = "cat $path | bzip2 -d";
$cmd = $cmd . " | tail -$tail" if defined $tail;
if ($logPath =~ /.bz2$/) {
$cmd = "bzip2 -d < $logPath";
$cmd = $cmd . " | tail -n $tail" if defined $tail;
}
else {
$cmd = defined $tail ? "tail -$tail $path" : "cat $path";
$cmd = defined $tail ? "tail -$tail $logPath" : "cat $logPath";
}
return `$cmd` if -e $path;
return `$cmd`;
}
sub removeAsciiEscapes {
my ($logtext) = @_;
$logtext =~ s/\e\[[0-9]*[A-Za-z]//g;

View file

@ -127,7 +127,12 @@ __PACKAGE__->belongs_to(
"build",
"Hydra::Schema::Builds",
{ id => "build" },
{ join_type => "LEFT" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "NO ACTION",
},
);
=head2 dependency
@ -142,11 +147,16 @@ __PACKAGE__->belongs_to(
"dependency",
"Hydra::Schema::Builds",
{ id => "dependency" },
{ join_type => "LEFT" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "NO ACTION",
},
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 12:38:16
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sav9OmLm3qA/jiK5k+KIjw
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:byU/SLN03zNJlSFbi/3Bcg
1;

View file

@ -71,12 +71,12 @@ __PACKAGE__->belongs_to(
"hostname",
"Hydra::Schema::BuildMachines",
{ hostname => "hostname" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CpwMC8YMFC4B7gzGBdzh0A
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:im3sfvrv5YY3i1IAOozeiA
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -109,12 +109,12 @@ __PACKAGE__->has_many(
"buildmachinesystemtypes",
"Hydra::Schema::BuildMachineSystemTypes",
{ "foreign.hostname" => "self.hostname" },
{},
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wboDtUIBUkvEiUHpe09kkg
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OST5IMcvHKsXlNMCRazXhg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -130,11 +130,16 @@ Related object: L<Hydra::Schema::Builds>
=cut
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }, {});
__PACKAGE__->belongs_to(
"build",
"Hydra::Schema::Builds",
{ id => "build" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-02-29 00:47:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dzTKwZ7bby7kplnSgta3Gw
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KHwh/Np40jxKXc3ijMImEQ
# You can replace this text with custom content, and it will be preserved on regeneration
1;

View file

@ -49,11 +49,6 @@ __PACKAGE__->table("BuildSteps");
data_type: 'text'
is_nullable: 1
=head2 logfile
data_type: 'text'
is_nullable: 1
=head2 busy
data_type: 'integer'
@ -103,8 +98,6 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"outpath",
{ data_type => "text", is_nullable => 1 },
"logfile",
{ data_type => "text", is_nullable => 1 },
"busy",
{ data_type => "integer", is_nullable => 0 },
"status",
@ -145,10 +138,15 @@ Related object: L<Hydra::Schema::Builds>
=cut
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }, {});
__PACKAGE__->belongs_to(
"build",
"Hydra::Schema::Builds",
{ id => "build" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5H+OkGT0zQEWkAjU+OlBdg
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ItI1OvxHfLTzLVEqfPRjHg
1;

View file

@ -183,11 +183,6 @@ __PACKAGE__->table("Builds");
data_type: 'text'
is_nullable: 1
=head2 logsize
data_type: 'bigint'
is_nullable: 1
=head2 size
data_type: 'bigint'
@ -272,8 +267,6 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_nullable => 1 },
"errormsg",
{ data_type => "text", is_nullable => 1 },
"logsize",
{ data_type => "bigint", is_nullable => 1 },
"size",
{ data_type => "bigint", is_nullable => 1 },
"closuresize",
@ -310,7 +303,7 @@ __PACKAGE__->has_many(
"buildinputs_builds",
"Hydra::Schema::BuildInputs",
{ "foreign.build" => "self.id" },
{},
undef,
);
=head2 buildinputs_dependencies
@ -325,7 +318,7 @@ __PACKAGE__->has_many(
"buildinputs_dependencies",
"Hydra::Schema::BuildInputs",
{ "foreign.dependency" => "self.id" },
{},
undef,
);
=head2 buildproducts
@ -340,7 +333,7 @@ __PACKAGE__->has_many(
"buildproducts",
"Hydra::Schema::BuildProducts",
{ "foreign.build" => "self.id" },
{},
undef,
);
=head2 buildsteps
@ -355,7 +348,7 @@ __PACKAGE__->has_many(
"buildsteps",
"Hydra::Schema::BuildSteps",
{ "foreign.build" => "self.id" },
{},
undef,
);
=head2 job
@ -370,7 +363,7 @@ __PACKAGE__->belongs_to(
"job",
"Hydra::Schema::Jobs",
{ jobset => "jobset", name => "job", project => "project" },
{},
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "CASCADE" },
);
=head2 jobset
@ -385,7 +378,7 @@ __PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Jobsets",
{ name => "jobset", project => "project" },
{},
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "CASCADE" },
);
=head2 jobsetevalinputs
@ -400,7 +393,7 @@ __PACKAGE__->has_many(
"jobsetevalinputs",
"Hydra::Schema::JobsetEvalInputs",
{ "foreign.dependency" => "self.id" },
{},
undef,
);
=head2 jobsetevalmembers
@ -415,7 +408,7 @@ __PACKAGE__->has_many(
"jobsetevalmembers",
"Hydra::Schema::JobsetEvalMembers",
{ "foreign.build" => "self.id" },
{},
undef,
);
=head2 project
@ -426,7 +419,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "CASCADE" },
);
=head2 releasemembers
@ -440,12 +438,12 @@ __PACKAGE__->has_many(
"releasemembers",
"Hydra::Schema::ReleaseMembers",
{ "foreign.build" => "self.id" },
{},
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AltTdmkzfwBMYToTkj84vA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:34:39
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wPBFqpUWncuD9xki8Pbnvg
__PACKAGE__->has_many(
"dependents",

View file

@ -122,7 +122,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.jobset",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 jobset
@ -137,7 +137,7 @@ __PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Jobsets",
{ name => "jobset", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 project
@ -148,10 +148,15 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZyDc4SrY9RfmsLK6VOqHhw
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Vfl4QtuyeKeEk9+Ap7FP2A
1;

View file

@ -130,7 +130,12 @@ __PACKAGE__->belongs_to(
"dependency",
"Hydra::Schema::Builds",
{ id => "dependency" },
{ join_type => "LEFT" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "NO ACTION",
},
);
=head2 eval
@ -141,11 +146,16 @@ Related object: L<Hydra::Schema::JobsetEvals>
=cut
__PACKAGE__->belongs_to("eval", "Hydra::Schema::JobsetEvals", { id => "eval" }, {});
__PACKAGE__->belongs_to(
"eval",
"Hydra::Schema::JobsetEvals",
{ id => "eval" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PNxVBdoUNeUzf5BztiIhLw
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ng+Q6tMX5EJMD7DxRWVy7Q
# You can replace this text with custom code or comments, and it will be preserved on regeneration

View file

@ -75,7 +75,12 @@ Related object: L<Hydra::Schema::Builds>
=cut
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }, {});
__PACKAGE__->belongs_to(
"build",
"Hydra::Schema::Builds",
{ id => "build" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
=head2 eval
@ -85,11 +90,16 @@ Related object: L<Hydra::Schema::JobsetEvals>
=cut
__PACKAGE__->belongs_to("eval", "Hydra::Schema::JobsetEvals", { id => "eval" }, {});
__PACKAGE__->belongs_to(
"eval",
"Hydra::Schema::JobsetEvals",
{ id => "eval" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0K4lDPUQeK04SEXS5yBbeA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EVwSR9WBqbBdIHq1ANQMHg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -127,7 +127,7 @@ __PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Jobsets",
{ name => "jobset", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 jobsetevalinputs
@ -142,7 +142,7 @@ __PACKAGE__->has_many(
"jobsetevalinputs",
"Hydra::Schema::JobsetEvalInputs",
{ "foreign.eval" => "self.id" },
{},
undef,
);
=head2 jobsetevalmembers
@ -157,7 +157,7 @@ __PACKAGE__->has_many(
"jobsetevalmembers",
"Hydra::Schema::JobsetEvalMembers",
{ "foreign.eval" => "self.id" },
{},
undef,
);
=head2 project
@ -168,11 +168,16 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 22:30:41
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jn81MbsAb5KZGwRpQ7qTEQ
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qElGj6zzuI0xo426np3r1w
__PACKAGE__->has_many(
"buildIds",

View file

@ -105,11 +105,11 @@ __PACKAGE__->belongs_to(
"jobsetinput",
"Hydra::Schema::JobsetInputs",
{ jobset => "jobset", name => "input", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 12:38:16
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:M1pOjrCZ2RgULsIPZjN7sg
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:M3pNBRLfxgSScrPj1zaajA
1;

View file

@ -88,7 +88,7 @@ __PACKAGE__->belongs_to(
"jobset",
"Hydra::Schema::Jobsets",
{ name => "jobset", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 jobsetinputalts
@ -107,7 +107,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.jobset",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 jobsets
@ -126,11 +126,11 @@ __PACKAGE__->has_many(
"foreign.nixexprinput" => "self.name",
"foreign.project" => "self.project",
},
{},
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F/eZhnWZHATn9+O6MzuPqA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xjioYUPo6visoLAVDkDZ0Q
1;

View file

@ -157,7 +157,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.name",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 jobs
@ -175,7 +175,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.name",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 jobsetevals
@ -193,7 +193,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.name",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 jobsetinput
@ -208,7 +208,7 @@ __PACKAGE__->belongs_to(
"jobsetinput",
"Hydra::Schema::JobsetInputs",
{ jobset => "name", name => "nixexprinput", project => "project" },
{},
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
=head2 jobsetinputs
@ -226,7 +226,7 @@ __PACKAGE__->has_many(
"foreign.jobset" => "self.name",
"foreign.project" => "self.project",
},
{},
undef,
);
=head2 project
@ -237,10 +237,15 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ikvo8+cq03DzjEUvXSqYiQ
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9smV/zbSSxQNLiBcnADFXA
1;

View file

@ -80,10 +80,15 @@ Related object: L<Hydra::Schema::Users>
=cut
__PACKAGE__->belongs_to("author", "Hydra::Schema::Users", { username => "author" }, {});
__PACKAGE__->belongs_to(
"author",
"Hydra::Schema::Users",
{ username => "author" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YRMh0QI4JezFLj7nywGu6Q
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lnA5Utkwk5WTyKA/M5mlyg
1;

View file

@ -68,7 +68,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 username
@ -82,12 +87,12 @@ __PACKAGE__->belongs_to(
"username",
"Hydra::Schema::Users",
{ username => "username" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:09p6h8c3+hRIjw3XmX15rA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zW87n6E7xWaShcFbgFkVuw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -106,7 +106,7 @@ __PACKAGE__->has_many(
"builds",
"Hydra::Schema::Builds",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 jobs
@ -121,7 +121,7 @@ __PACKAGE__->has_many(
"jobs",
"Hydra::Schema::Jobs",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 jobsetevals
@ -136,7 +136,7 @@ __PACKAGE__->has_many(
"jobsetevals",
"Hydra::Schema::JobsetEvals",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 jobsets
@ -151,7 +151,7 @@ __PACKAGE__->has_many(
"jobsets",
"Hydra::Schema::Jobsets",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 owner
@ -162,7 +162,12 @@ Related object: L<Hydra::Schema::Users>
=cut
__PACKAGE__->belongs_to("owner", "Hydra::Schema::Users", { username => "owner" }, {});
__PACKAGE__->belongs_to(
"owner",
"Hydra::Schema::Users",
{ username => "owner" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "CASCADE" },
);
=head2 projectmembers
@ -176,7 +181,7 @@ __PACKAGE__->has_many(
"projectmembers",
"Hydra::Schema::ProjectMembers",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 releasemembers
@ -191,7 +196,7 @@ __PACKAGE__->has_many(
"releasemembers",
"Hydra::Schema::ReleaseMembers",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 releases
@ -206,7 +211,7 @@ __PACKAGE__->has_many(
"releases",
"Hydra::Schema::Releases",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 viewjobs
@ -221,7 +226,7 @@ __PACKAGE__->has_many(
"viewjobs",
"Hydra::Schema::ViewJobs",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 views
@ -236,12 +241,22 @@ __PACKAGE__->has_many(
"views",
"Hydra::Schema::Views",
{ "foreign.project" => "self.name" },
{},
undef,
);
=head2 usernames
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cnheEOmK/5fCX1ui4OWPog
Type: many_to_many
Composing rels: L</projectmembers> -> username
=cut
__PACKAGE__->many_to_many("usernames", "projectmembers", "username");
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OCuhmxs8pZxvmk81eVLLcQ
# These lines were loaded from '/home/rbvermaa/src/hydra/src/lib/Hydra/Schema/Projects.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete

View file

@ -85,7 +85,12 @@ Related object: L<Hydra::Schema::Builds>
=cut
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }, {});
__PACKAGE__->belongs_to(
"build",
"Hydra::Schema::Builds",
{ id => "build" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
=head2 project
@ -95,7 +100,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 release
@ -109,11 +119,11 @@ __PACKAGE__->belongs_to(
"release",
"Hydra::Schema::Releases",
{ name => "release_", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SBMfzENPE0BjEwc2HAK7IA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eP00w5UJp1uTtiB7D5IhTQ
1;

View file

@ -81,7 +81,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
);
=head2 releasemembers
@ -98,11 +103,11 @@ __PACKAGE__->has_many(
"foreign.project" => "self.project",
"foreign.release_" => "self.name",
},
{},
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W6GOMPv7hc2EAdVaBOvc3A
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UTUE3Hb89fT7prwnwwBgvQ
1;

View file

@ -71,11 +71,11 @@ __PACKAGE__->belongs_to(
"username",
"Hydra::Schema::Users",
{ username => "username" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TySGsLoTpeSuThILIXUaVg
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KArPHyemtnm/siwE4x5mGQ
1;

View file

@ -90,7 +90,7 @@ __PACKAGE__->has_many(
"newsitems",
"Hydra::Schema::NewsItems",
{ "foreign.author" => "self.username" },
{},
undef,
);
=head2 projectmembers
@ -105,10 +105,10 @@ __PACKAGE__->has_many(
"projectmembers",
"Hydra::Schema::ProjectMembers",
{ "foreign.username" => "self.username" },
{},
undef,
);
=head2 projects
=head2 projects_2s
Type: has_many
@ -117,10 +117,10 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->has_many(
"projects",
"projects_2s",
"Hydra::Schema::Projects",
{ "foreign.owner" => "self.username" },
{},
undef,
);
=head2 userroles
@ -135,12 +135,22 @@ __PACKAGE__->has_many(
"userroles",
"Hydra::Schema::UserRoles",
{ "foreign.username" => "self.username" },
{},
undef,
);
=head2 projects
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3fmr8WMAE9Dg7TKom76YIQ
Type: many_to_many
Composing rels: L</projectmembers> -> project
=cut
__PACKAGE__->many_to_many("projects", "projectmembers", "project");
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OAUFl/teGpfeleb6D8FPlw
# These lines were loaded from '/home/rbvermaa/src/hydra/src/lib/Hydra/Schema/Users.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete

View file

@ -116,7 +116,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 view
@ -130,11 +135,11 @@ __PACKAGE__->belongs_to(
"view",
"Hydra::Schema::Views",
{ name => "view_", project => "project" },
{},
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U9/ovaBs9kFO3flG/MZ5uA
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cbSUw113ENPypbd/sICfgg
1;

View file

@ -82,7 +82,12 @@ Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {});
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 viewjobs
@ -96,11 +101,11 @@ __PACKAGE__->has_many(
"viewjobs",
"Hydra::Schema::ViewJobs",
{ "foreign.project" => "self.project", "foreign.view_" => "self.name" },
{},
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cP9XYKw4y9QL+PDJYy9M5w
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-01-22 13:29:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Vyd2+0RAF3XGTpq3KswfAQ
1;

View file

@ -2,7 +2,16 @@ package Hydra::View::TT;
use strict;
use base 'Catalyst::View::TT';
use Hydra::Helper::Nix;
__PACKAGE__->config(TEMPLATE_EXTENSION => '.tt');
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
expose_methods => [qw/log_exists/]);
sub log_exists {
my ($self, $c, $drvPath) = @_;
my $x = getDrvLogPath($drvPath);
return defined $x;
}
1;

View file

@ -16,9 +16,9 @@
<tbody>
[% FOREACH step IN build.buildsteps -%]
[% IF ( type == "All" ) || ( type == "Failed" && step.status != 0 ) || ( type == "Running" && step.busy == 1 ) -%]
[% log = c.uri_for('/build' build.id 'nixlog' step.stepnr) %]
<tr class="[% IF step.logfile %]clickable[% END %]"
[% IF step.logfile %] onclick="window.location = '[% log %]'" [% END %]>
[% has_log = log_exists(step.drvpath);
log = c.uri_for('/build' build.id 'nixlog' step.stepnr); -%]
<tr [% IF has_log %] class="clickable" onclick="window.location = '[% log %]'" [% END %]>
<td>[% step.stepnr %]</td>
<td>
[% IF step.type == 0 %]
@ -51,7 +51,7 @@
[% ELSE %]
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
[% END %]
[% IF step.logfile %]
[% IF has_log %]
(<a href="[% log %]">log</a>, <a href="[% "$log/raw" %]">raw</a>, <a href="[% "$log/tail-reload" %]">tail</a>)
[% END %]
</td>
@ -124,11 +124,11 @@
</td>
</tr>
[% END %]
[% IF build.logfile %]
[% IF log_exists(build.drvpath) %]
<tr>
<th>Logfile:</th>
<td>
<a class="btn btn-mini btn-primary" href="[% c.uri_for('/build' build.id 'log') %]">pretty</a>
<a class="btn btn-mini" href="[% c.uri_for('/build' build.id 'log') %]">pretty</a>
<a class="btn btn-mini" href="[% c.uri_for('/build' build.id 'log' 'raw') %]">raw</a>
<a class="btn btn-mini" href="[% c.uri_for('/build' build.id 'log' 'tail-reload') %]">tail</a>
</td>
@ -208,9 +208,9 @@
<pre class="buildlog">[% HTML.escape(build.errormsg) -%]</pre>
[% END %]
[% END %]
[% IF logtext %]
<h2>Log</h2>
<pre class="buildlog">[% HTML.escape(logtext) -%]</pre>
[% END %]
</div>
@ -275,16 +275,12 @@
</tr>
<tr>
<th>Maintainer(s):</th>
<td>[% IF build.maintainers %]<tt>[% HTML.escape(build.maintainers) %]</tt>[% ELSE %]<em>(not given)</em>[% END %]</td>
<td>[% IF build.maintainers %][% HTML.escape(build.maintainers) %][% ELSE %]<em>(not given)</em>[% END %]</td>
</tr>
<tr>
<th>System:</th>
<td><tt>[% build.system %]</tt></td>
</tr>
<tr>
<th>Max silent / timeout:</th>
<td>[% build.maxsilent %]s / [% build.timeout %]s</td>
</tr>
<tr>
<th>Derivation store path:</th>
<td>
@ -322,7 +318,6 @@
<td>[% INCLUDE renderFullBuildLink build=cachedBuild %]</td>
</tr>
[% END %]
<tr>
<th>Build started:</th>
<td>[% IF build.starttime %][% INCLUDE renderDateTime timestamp = build.starttime %][% ELSE %]<em>(cached build)</em>[% END %]</td>
@ -331,26 +326,6 @@
<th>Build finished:</th>
<td>[% IF build.stoptime %][% INCLUDE renderDateTime timestamp = build.stoptime %][% ELSE %]<em>(cached build)</em>[% END %]</td>
</tr>
<tr>
<th>Duration:</th>
<td>
[% IF build.iscachedbuild %]
<em>(cached build)</em>
[% ELSE %]
[% INCLUDE renderDuration duration = build.stoptime - build.starttime %]
[% END %]
</td>
</tr>
[% IF build.logfile %]
<tr>
<th>Logfile:</th>
<td>
<a href="[% c.uri_for('/build' build.id 'log') %]"><strong>Available</strong></a>
(<a href="[% c.uri_for('/build' build.id 'log' 'raw') %]">raw</a>,
<a href="[% c.uri_for('/build' build.id 'log' 'tail-reload') %]">tail</a>)
</td>
</tr>
[% END %]
[% END %]
[% IF !build.finished %]
<tr>
@ -406,7 +381,7 @@
<p/>
[% IF prevBuild %]
<h3>Changes since previous build : [% INCLUDE renderFullBuildLink build=prevBuild, hideProjectName=1, hideJobsetName=1 %]</h3>
<h3>Changes since previous build: [% INCLUDE renderFullBuildLink build=prevBuild, hideProjectName=1, hideJobsetName=1 %]</h3>
[% INCLUDE renderInputDiff build2=build , build1=prevBuild %]
[% END %]

View file

@ -156,7 +156,7 @@ sub sendEmailNotification {
$inputsTable->load(@lines);
my $loglines = 50;
my $logtext = logContents($build->logfile, $loglines);
my $logtext = logContents($build->drvpath, $loglines);
$logtext = removeAsciiEscapes($logtext);
my $body = "Hi,\n"
@ -267,7 +267,6 @@ sub doBuild {
, drvpath => $drvPathStep
, outpath => $2
, system => $3
, logfile => $4
, busy => 1
, starttime => time
});
@ -314,7 +313,6 @@ sub doBuild {
, type => 0 # = build
, drvpath => $drvPathStep
, outpath => $2
, logfile => getBuildLog($drvPathStep)
, busy => 0
, status => 1
, starttime => time
@ -376,10 +374,6 @@ sub doBuild {
}
done:
my $logfile = getBuildLog($drvPath);
my $logsize = defined $logfile ? stat($logfile)->size : 0;
my $size = 0;
my $closuresize = 0;
@ -409,8 +403,6 @@ sub doBuild {
, buildstatus => $buildStatus
, starttime => $startTime
, stoptime => $stopTime
, logfile => $logfile
, logsize => $logsize
, size => $size
, closuresize => $closuresize
, errormsg => $errormsg

View file

@ -40,9 +40,7 @@ sub unlockDeadBuilds {
}
if ($unlock) {
print "build ", $build->id, " pid $pid died, unlocking\n";
$build->busy(0);
$build->locker("");
$build->update;
$build->update({ busy => 0, locker => ""});
}
}
});
@ -63,8 +61,8 @@ sub findBuildDependencyInQueue {
return unless scalar @drvs > 0;
($depBuild) = $db->resultset('Builds')->search(
{ drvpath => [ @drvs ], finished => 0, busy => 0, enabled => 1, disabled => 0 },
{ join => ['project'], rows => 1 } ) ;
{ drvpath => [ @drvs ], finished => 0, busy => 0, enabled => 1, disabled => 0 },
{ join => ['project'], rows => 1 } ) ;
return $depBuild;
}
@ -113,11 +111,12 @@ sub checkBuilds {
my $logfile = getcwd . "/logs/" . $build->id;
mkdir(dirname $logfile);
unlink($logfile);
$build->busy(1);
$build->locker($$);
$build->logfile($logfile);
$build->starttime(time);
$build->update;
$build->update(
{ busy => 1
, locker => $$
, logfile => $logfile
, starttime => time()
});
push @buildsStarted, $build;
}
}

View file

@ -178,7 +178,6 @@ create table Builds (
errorMsg text, -- error message in case of a Nix failure
logSize bigint,
size bigint,
closureSize bigint,
@ -201,8 +200,6 @@ create table BuildSteps (
drvPath text,
outPath text,
logfile text,
busy integer not null,
status integer, -- 0 = success, 1 = failed