Skip to content

Commit

Permalink
[backend] Checker: add read_packstatus method
Browse files Browse the repository at this point in the history
This allows us to cache the packstatus in the future.
  • Loading branch information
mlschroe committed Mar 14, 2023
1 parent 054096e commit 7679699
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/backend/BSRepServer/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ sub read_gbininfo {
return BSRepServer::read_gbininfo("$reporoot/$prp/$arch");
}

sub read_packstatus {
my ($ctx, $prp, $arch) = @_;
return {};
}

sub writejob {
my ($ctx, $job, $binfo, $reason) = @_;
$ctx = $ctx->{'realctx'} if $ctx->{'realctx'};
Expand Down
15 changes: 15 additions & 0 deletions src/backend/BSSched/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,9 @@ sub addrepo {
my ($projid, $repoid) = split('/', $prp, 2);
my $remoteprojs = $gctx->{'remoteprojs'};
if ($remoteprojs->{$projid}) {
return 0 if ($ctx->{'addrepo_remote_inprogress'} || {})->{"$prp/$arch"};
$r = BSSched::Remote::addrepo_remote($ctx, $pool, $prp, $arch, $remoteprojs->{$projid});
$ctx->{'addrepo_remote_inprogress'}->{"$prp/$arch"} = 1 if !$r && defined($r);
} elsif ($arch ne $gctx->{'arch'}) {
my $alien_cache = $ctx->{'alien_repo_cache'};
$alien_cache = $ctx->{'alien_repo_cache'} = {} unless $alien_cache;
Expand Down Expand Up @@ -1561,6 +1563,19 @@ sub rebuild_gbininfo {
BSSched::BuildResult::rebuild_gbininfo($dir);
}

sub read_packstatus {
my ($ctx, $prp, $arch) = @_;
my $reporoot = $ctx->{'gctx'}->{'reporoot'};
return {} unless -e "$reporoot/$prp/$arch/:packstatus";
my $ps = BSUtil::retrieve("$reporoot/$prp/$arch/:packstatus", 1);
if (!$ps) {
# compat with very old obs versions
$ps = (readxml("$reporoot/$prp/$arch/:packstatus", $BSXML::packstatuslist, 1) || {})->{'packstatus'} || [];
return { map {$_->{'name'} => $_->{'status'}} @$ps };
}
return ($ps || {})->{'packstatus'} || {};
}

sub writejob {
return BSSched::BuildJob::writejob(@_);
}
Expand Down

0 comments on commit 7679699

Please sign in to comment.