From dcdbb1d814b3b3766fc309b4e53f8e541ff1d802 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Thu, 11 Nov 2010 11:03:50 +0000 Subject: [PATCH] hydra: store logfile/output path/closure size --- src/lib/Hydra/Schema/BuildMachines.pm | 35 +++++++------------------ src/lib/Hydra/Schema/BuildResultInfo.pm | 31 ++++++++++++++++++++-- src/script/hydra_build.pl.in | 19 +++++++++++++- src/sql/hydra.sql | 6 ++++- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/src/lib/Hydra/Schema/BuildMachines.pm b/src/lib/Hydra/Schema/BuildMachines.pm index ab615f33..e1e70184 100644 --- a/src/lib/Hydra/Schema/BuildMachines.pm +++ b/src/lib/Hydra/Schema/BuildMachines.pm @@ -29,21 +29,21 @@ __PACKAGE__->table("BuildMachines"); =head2 username data_type: text - default_value: undef + default_value: '' is_nullable: 0 size: undef =head2 ssh_key data_type: text - default_value: undef + default_value: '' is_nullable: 0 size: undef =head2 options data_type: text - default_value: undef + default_value: '' is_nullable: 0 size: undef @@ -64,7 +64,7 @@ __PACKAGE__->table("BuildMachines"); =head2 enabled data_type: integer - default_value: 1 + default_value: 0 is_nullable: 0 size: undef @@ -79,32 +79,17 @@ __PACKAGE__->add_columns( size => undef, }, "username", - { - data_type => "text", - default_value => undef, - is_nullable => 0, - size => undef, - }, + { data_type => "text", default_value => "''", is_nullable => 0, size => undef }, "ssh_key", - { - data_type => "text", - default_value => undef, - is_nullable => 0, - size => undef, - }, + { data_type => "text", default_value => "''", is_nullable => 0, size => undef }, "options", - { - data_type => "text", - default_value => undef, - is_nullable => 0, - size => undef, - }, + { data_type => "text", default_value => "''", is_nullable => 0, size => undef }, "maxconcurrent", { data_type => "integer", default_value => 2, is_nullable => 0, size => undef }, "speedfactor", { data_type => "integer", default_value => 1, is_nullable => 0, size => undef }, "enabled", - { data_type => "integer", default_value => 1, is_nullable => 0, size => undef }, + { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("hostname"); @@ -125,8 +110,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-10-11 12:58:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gje+VA73Hghl7JXp+Fl8pw +# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-11-11 10:58:44 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GV0LlwTyjFctix2zArVTGw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildResultInfo.pm b/src/lib/Hydra/Schema/BuildResultInfo.pm index f7ca7035..9710ee8e 100644 --- a/src/lib/Hydra/Schema/BuildResultInfo.pm +++ b/src/lib/Hydra/Schema/BuildResultInfo.pm @@ -69,6 +69,27 @@ __PACKAGE__->table("BuildResultInfo"); is_nullable: 1 size: undef +=head2 logsize + + data_type: integer + default_value: 0 + is_nullable: 0 + size: undef + +=head2 size + + data_type: integer + default_value: 0 + is_nullable: 0 + size: undef + +=head2 closuresize + + data_type: integer + default_value: 0 + is_nullable: 0 + size: undef + =head2 releasename data_type: text @@ -150,6 +171,12 @@ __PACKAGE__->add_columns( is_nullable => 1, size => undef, }, + "logsize", + { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, + "size", + { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, + "closuresize", + { data_type => "integer", default_value => 0, is_nullable => 0, size => undef }, "releasename", { data_type => "text", @@ -189,8 +216,8 @@ Related object: L __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }, {}); -# Created by DBIx::Class::Schema::Loader v0.05003 @ 2010-02-25 10:29:41 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Vg+v2gK8l7iqBqQGtZJ1cA +# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-11-11 10:58:44 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7RntgXzDYpnfVLfja5RXKg __PACKAGE__->belongs_to( "failedDep", diff --git a/src/script/hydra_build.pl.in b/src/script/hydra_build.pl.in index 2b1b9582..9a6f5a66 100755 --- a/src/script/hydra_build.pl.in +++ b/src/script/hydra_build.pl.in @@ -199,6 +199,10 @@ sub sendEmailNotification { sendmail($email); } +sub getSize { + my $size = `du -bcs @_ 2> /dev/null | tail -1 | cut -f 1 `; + return int($size); +} sub doBuild { my ($build) = @_; @@ -365,6 +369,16 @@ sub doBuild { } done: + my $logfile = getBuildLog($drvPath); + + my $logsize = defined $logfile ? getSize($logfile) : 0; + my $size = isValidPath($outPath) ? getSize($outPath) : 0; + + my $closuresize = 0; + if (isValidPath($outPath)) { + (my $hash, my $deriver, my $refs) = queryPathInfo($outPath) ; + $closuresize = getSize(@{$refs}); + } txn_do($db, sub { $build->update({finished => 1, timestamp => time}); @@ -377,7 +391,10 @@ sub doBuild { , buildstatus => $buildStatus , starttime => $startTime , stoptime => $stopTime - , logfile => getBuildLog($drvPath) + , logfile => $logfile + , logsize => $logsize + , size => $size + , closuresize => $closuresize , errormsg => $errormsg , releasename => $releaseName }); diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 528e920a..ca934430 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -114,7 +114,7 @@ create table Jobs ( ); --- This table contains all builds, either scheduled or finished. For +-- This table contains all wbuilds, either scheduled or finished. For -- scheduled builds, additional info (such as the priority) can be -- found in the BuildSchedulingInfo table. For finished builds, -- additional info (such as the logs, build products, etc.) can be @@ -204,6 +204,10 @@ create table BuildResultInfo ( logfile text, -- the path of the logfile + logsize integer not null default 0, + size integer not null default 0, + closuresize integer not null default 0, + releaseName text, -- e.g. "patchelf-0.5pre1234" keep integer not null default 0, -- true means never garbage-collect the build output