From 8725dc03ec0c39f684a8e761cd328b97d1b6e81d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 9 Mar 2009 16:22:41 +0000 Subject: [PATCH] * Use ->update({...}) properly. --- src/lib/Hydra/Controller/Build.pm | 4 +--- src/lib/Hydra/Controller/Project.pm | 12 ++++------ src/lib/Hydra/Controller/Root.pm | 6 ++--- src/script/hydra_build.pl | 36 +++++++---------------------- src/script/hydra_scheduler.pl | 10 +++----- 5 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index c0e5802c..3c1c15fb 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -175,9 +175,7 @@ sub restart : Chained('build') PathPart Args(0) { ($build->resultInfo->buildstatus == 3 || $build->resultInfo->buildstatus == 4); - $build->finished(0); - $build->timestamp(time()); - $build->update; + $build->update({finished => 0, timestamp => time}); $build->resultInfo->delete; diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 21d50f93..e61fe6e8 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -153,11 +153,9 @@ sub updateProject { } else { # it's an existing jobset $jobset = ($project->jobsets->search({name => $baseName}))[0]; die unless defined $jobset; - $jobset->name($jobsetName); - $jobset->description($description); - $jobset->nixexprpath($nixExprPath); - $jobset->nixexprinput($nixExprInput); - $jobset->update; + $jobset->update( + { name => $jobsetName, description => $description + , nixexprpath => $nixExprPath, nixexprinput => $nixExprInput }); } my %inputNames; @@ -189,9 +187,7 @@ sub updateProject { } else { # it's an existing jobset $input = ($jobset->jobsetinputs->search({name => $baseName2}))[0]; die unless defined $input; - $input->name($inputName); - $input->type($inputType); - $input->update; + $input->update({name => $inputName, type => $inputType}); } # Update the values for this input. Just delete all the diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index fd8dfd36..1c97212c 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -103,9 +103,9 @@ sub updateReleaseSet { my $releaseSetName = trim $c->request->params->{name}; die "Invalid release set name: $releaseSetName" unless $releaseSetName =~ /^[[:alpha:]]\w*$/; - $releaseSet->name($releaseSetName); - $releaseSet->description(trim $c->request->params->{description}); - $releaseSet->update; + $releaseSet->update( + { name => $releaseSetName + , description => trim $c->request->params->{description} }); $releaseSet->releasesetjobs->delete_all; diff --git a/src/script/hydra_build.pl b/src/script/hydra_build.pl index 9470e564..8a1fef4d 100755 --- a/src/script/hydra_build.pl +++ b/src/script/hydra_build.pl @@ -30,6 +30,7 @@ sub doBuild { if (!isValidPath($outPath)) { $isCachedBuild = 0; + # Do the build. $startTime = time(); my $thisBuildFailed = 0; @@ -74,10 +75,7 @@ sub doBuild { (my $step) = $db->resultset('BuildSteps')->search( {id => $build->id, type => 0, drvpath => $drvPath}, {}); die unless $step; - $step->busy(0); - $step->status(0); - $step->stoptime(time); - $step->update; + $step->update({busy => 0, status => 0, time => 0}); }); } @@ -89,12 +87,7 @@ sub doBuild { (my $step) = $db->resultset('BuildSteps')->search( {id => $build->id, type => 0, drvpath => $drvPathStep}, {}); if ($step) { - die unless $step; - $step->busy(0); - $step->status(1); - $step->errormsg($4); - $step->stoptime(time); - $step->update; + $step->update({busy => 0, status => 1, errormsg => $4, stoptime => time}); } else { $db->resultset('BuildSteps')->create( { id => $build->id @@ -133,10 +126,7 @@ sub doBuild { (my $step) = $db->resultset('BuildSteps')->search( {id => $build->id, type => 1, outpath => $outPath}, {}); die unless $step; - $step->busy(0); - $step->status(0); - $step->stoptime(time); - $step->update; + $step->update({busy => 0, status => 0, stoptime => time}); }); } @@ -146,11 +136,7 @@ sub doBuild { (my $step) = $db->resultset('BuildSteps')->search( {id => $build->id, type => 1, outpath => $outPath}, {}); die unless $step; - $step->busy(0); - $step->status(1); - $step->errormsg($3); - $step->stoptime(time); - $step->update; + $step->update({busy => 0, status => 1, errormsg => $3, stoptime => time}); }); } @@ -176,9 +162,7 @@ sub doBuild { } $db->txn_do(sub { - $build->finished(1); - $build->timestamp(time()); - $build->update; + $build->({finished => 1, timestamp => time}); my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath; $logPath = undef unless -e $logPath; @@ -283,9 +267,7 @@ $db->txn_do(sub { if ($build->schedulingInfo->busy != 0 && $build->schedulingInfo->locker != getppid) { die "build $buildId is already being built"; } - $build->schedulingInfo->busy(1); - $build->schedulingInfo->locker($$); - $build->schedulingInfo->update; + $build->schedulingInfo->update({busy => 1, locker => $$}); $build->buildsteps->delete_all; $build->buildproducts->delete_all; }); @@ -301,8 +283,6 @@ eval { if ($@) { warn $@; $db->txn_do(sub { - $build->schedulingInfo->busy(0); - $build->schedulingInfo->locker($$); - $build->schedulingInfo->update; + $build->schedulingInfo->update({busy => 0, locker => $$}); }); } diff --git a/src/script/hydra_scheduler.pl b/src/script/hydra_scheduler.pl index f6fc6fa3..ff1e7f0d 100755 --- a/src/script/hydra_scheduler.pl +++ b/src/script/hydra_scheduler.pl @@ -84,8 +84,7 @@ sub fetchInputAlt { } else { $timestamp = $cachedInput->timestamp; $db->txn_do(sub { - $cachedInput->lastseen(time); - $cachedInput->update; + $cachedInput->update({lastseen => time}); }); } } @@ -274,9 +273,7 @@ sub setJobsetError { my ($jobset, $errorMsg) = @_; eval { $db->txn_do(sub { - $jobset->errormsg($errorMsg); - $jobset->errortime(time); - $jobset->update; + $jobset->update({errormsg => $errorMsg, errortime => time}); }); }; } @@ -316,8 +313,7 @@ sub checkJobSet { my $inputInfo = {}; $db->txn_do(sub { - $jobset->lastcheckedtime(time); - $jobset->update; + $jobset->update({lastcheckedtime => time}); }); # Fetch all values for all inputs.