Skip to content

Commit

Permalink
[backend] also patch the packstatus state for finished aggregates, so…
Browse files Browse the repository at this point in the history
… that the build state doesn't fall back to succeeeded if we have lots of medium events
  • Loading branch information
mlschroe committed Mar 16, 2012
1 parent a2ae1f9 commit 4774ca9
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions src/backend/bs_sched
Expand Up @@ -2456,6 +2456,40 @@ sub addrepo_remote {
}
}

#
# patch the packstatus entry of package $packid so that it
# reflects the finished state
#
sub patchpackstatus {
my ($prp, $packid, $code) = @_;

my $ps = BSUtil::retrieve("$reporoot/$prp/$myarch/:packstatus", 1);
if ($ps) {
if (exists($ps->{'packstatus'}->{$packid})) {
$ps->{'packstatus'}->{$packid} = 'finished';
$ps->{'packerror'}->{$packid} = $code;
BSUtil::store("$reporoot/$prp/$myarch/.:packstatus", "$reporoot/$prp/$myarch/:packstatus", $ps);
}
} else {
# compatibility: read and convert old xml data
$ps = readxml("$reporoot/$prp/$myarch/:packstatus", $BSXML::packstatuslist, 1);
if ($ps) {
my %packstatus;
my %packerror;
for (@{$ps->{'packstatus'} || []}) {
$packstatus{$_->{'name'}} = $_->{'status'};
$packerror{$_->{'name'}} = $_->{'error'} if $_->{'error'};
}
if (exists($packstatus{$packid})) {
$packstatus{$packid} = 'finished';
$packerror{$packid} = $code;
}
$ps = {'packstatus' => \%packstatus, 'packerror' => \%packerror};
BSUtil::store("$reporoot/$prp/$myarch/.:packstatus", "$reporoot/$prp/$myarch/:packstatus", $ps);
}
}
}

#
# jobfinished - called when a build job is finished
#
Expand Down Expand Up @@ -2550,31 +2584,7 @@ sub jobfinished {
}

# update packstatus so that it doesn't fall back to scheduled
my $ps = BSUtil::retrieve("$reporoot/$prp/$myarch/:packstatus", 1);
if ($ps) {
if (exists($ps->{'packstatus'}->{$packid})) {
$ps->{'packstatus'}->{$packid} = 'finished';
$ps->{'packerror'}->{$packid} = $code;
BSUtil::store("$reporoot/$prp/$myarch/.:packstatus", "$reporoot/$prp/$myarch/:packstatus", $ps);
}
} else {
# compatibility: read and convert old xml data
$ps = readxml("$reporoot/$prp/$myarch/:packstatus", $BSXML::packstatuslist, 1);
if ($ps) {
my %packstatus;
my %packerror;
for (@{$ps->{'packstatus'} || []}) {
$packstatus{$_->{'name'}} = $_->{'status'};
$packerror{$_->{'name'}} = $_->{'error'} if $_->{'error'};
}
if (exists($packstatus{$packid})) {
$packstatus{$packid} = 'finished';
$packerror{$packid} = $code;
}
$ps = {'packstatus' => \%packstatus, 'packerror' => \%packerror};
BSUtil::store("$reporoot/$prp/$myarch/.:packstatus", "$reporoot/$prp/$myarch/:packstatus", $ps);
}
}
patchpackstatus($prp, $packid, $code);

my $meta = $all{'meta'} ? "$jobdatadir/meta" : undef;
if ($code eq 'unchanged') {
Expand Down Expand Up @@ -2695,6 +2705,7 @@ sub aggregatefinished {
unlink("$dst/status");
mkdir_p("$gdst/:meta");
rename("$jobdatadir/meta", "$gdst/:meta/$packid") || die("rename $jobdatadir/meta $gdst/:meta/$packid: $!\n");
patchpackstatus($prp, $packid, 'succeeded');
}

sub deltafinished {
Expand Down

0 comments on commit 4774ca9

Please sign in to comment.