Skip to content

Commit

Permalink
[backend] support details in schedulerstate
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jan 23, 2012
1 parent e3a3591 commit 8271982
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
9 changes: 2 additions & 7 deletions src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,6 @@ our $packstatuslist = [
]],
];

our $packstatuslistlist = [
'packstatuslistlist' =>
'state',
'retryafter',
[ $packstatuslist ],
];

our $linkpatch = [
'' =>
[ 'add' =>
Expand Down Expand Up @@ -851,6 +844,7 @@ our $result = [
'repository',
'arch',
'state', # pra state, can be "unknown", "broken", "scheduling", "blocked", "building", "finished", "publishing", "published" or "unpublished"
'details',
'dirty', # marked for re-scheduling if element exists, state might not be correct anymore
[ $buildstatus ],
[ $binarylist ],
Expand Down Expand Up @@ -1013,6 +1007,7 @@ our $request = [
'id',
'type', # obsolete, still here to handle OBS pre-1.5 requests
'key', # cache key, not really in request
'retryafter', # timed out waiting for a key change
[[ 'action' =>
'type', # currently submit, delete, change_devel, add_role, maintenance_release, maintenance_incident, set_bugowner
[ 'source' =>
Expand Down
16 changes: 9 additions & 7 deletions src/backend/bs_repserver
Original file line number Diff line number Diff line change
Expand Up @@ -1115,17 +1115,18 @@ sub getschedulerstate {
my ($projid, $repoid, $arch) = @_;
local *F;

open(F, '<', "$reporoot/$projid/$repoid/$arch/:schedulerstate") || return 'unknown';
my $schedulerstate = readline(*F);
close(F);
my $schedulerstate = readstr("$reporoot/$projid/$repoid/$arch/:schedulerstate", 1) || 'unknown';
chomp $schedulerstate;
my $details;
($schedulerstate, $details) = split(' ', $schedulerstate, 2);

if ($schedulerstate eq 'finished') {
if ($schedulerstate eq 'finished' && !$details) {
return 'finished' if -e "$eventdir/publish/${projid}::$repoid";
return 'publishing' if -e "$eventdir/publish/${projid}::${repoid}::inprogress";
return 'unpublished' if (readstr("$reporoot/$projid/$repoid/$arch/:repodone",1) || '') eq 'disabled';
return 'unpublished' if (readstr("$reporoot/$projid/$repoid/$arch/:repodone", 1) || '') eq 'disabled';
return 'published';
}
return $schedulerstate;
return ($schedulerstate, $details);
}

sub workerstatus {
Expand Down Expand Up @@ -1631,8 +1632,9 @@ sub getresult {
$ps->{'packststus'}->{$_} ||= 'unknown';
}
}
my $schedulerstate = getschedulerstate($projid, $repoid, $arch);
my ($schedulerstate, $schedulerdetails) = getschedulerstate($projid, $repoid, $arch);
my $sl = {'project' => $projid, 'repository' => $repoid, 'arch' => $arch, 'state' => $schedulerstate };
$sl->{'details'} = $schedulerdetails if defined $schedulerdetails;
$sl->{'dirty'} = 'true' if -e "$reporoot/$prpa/:schedulerstate.dirty";
$sl->{'dirty'} = 'true' if $schedulerstate eq 'scheduling'; # flag already removed, but new state not yet written
fixpackstatus($prpa, $ps, \%buildingjobs);
Expand Down
30 changes: 19 additions & 11 deletions src/backend/bs_sched
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,12 @@ sub sendrepochangeevent {
}

sub set_repo_state {
my ($prp, $state) = @_;
my ($prp, $state, $details) = @_;

unlink("$reporoot/$prp/$myarch/:schedulerstate.dirty") if $state eq "scheduling";

writestr("$reporoot/$prp/$myarch/:schedulerstate.new", "$reporoot/$prp/$myarch/:schedulerstate", $state) if -e "$reporoot/$prp/$myarch";
$state .= " $details" if $details;
writestr("$reporoot/$prp/$myarch/:schedulerstate.new", "$reporoot/$prp/$myarch/:schedulerstate", $state) if -d "$reporoot/$prp/$myarch";
}


Expand Down Expand Up @@ -927,7 +928,7 @@ sub makedeltas {
if (-e "$myjobsdir/$job") {
# delta creation already in progress. wait...
print " delta creation already in progress...\n";
return undef, "in progress";
return undef, 'building';
}
my $srcmd5 = '';
$srcmd5 .= $_->[2] for @needdelta;
Expand Down Expand Up @@ -1140,7 +1141,9 @@ sub prpfinished {
my ($deltas, $err) = makedeltas($prp, $needdeltas ? $packs : undef, $pubenabled, $bconf, $prpsearchpath);
if (!$deltas) {
close(F);
return $err || 'error';
$err ||= 'internal error';
$err = "delta generation: $err";
return $err;
}

my $rdir = "$reporoot/$prp/$myarch/:repo";
Expand Down Expand Up @@ -5166,15 +5169,15 @@ while(1) {
next if $error;
my $lastprojid = (split('/', $prpsearchpath{$prp}->[-1]))[0];
print " - $prp: no config ($lastprojid)\n";
set_repo_state($prp, 'broken');
set_repo_state($prp, 'broken', "no config ($lastprojid)");
$prpfinished{$prp} = 1;
next;
}
my $prptype = $bconf->{'type'};
if (!$prptype || $prptype eq 'UNDEFINED') {
my $lastprojid = (split('/', $prpsearchpath{$prp}->[-1]))[0];
print " - $prp: bad config ($lastprojid)\n";
set_repo_state($prp, 'broken');
set_repo_state($prp, 'broken', "bad config ($lastprojid)");
$prpfinished{$prp} = 1;
next;
}
Expand All @@ -5191,7 +5194,7 @@ while(1) {
}

mkdir_p("$reporoot/$prp/$myarch");
set_repo_state($prp, "scheduling");
set_repo_state($prp, 'scheduling');

my $packs = $projpacks->{$projid}->{'package'} || {};
my @packs = sort keys %$packs;
Expand Down Expand Up @@ -5258,7 +5261,7 @@ while(1) {
}
if ($error) {
print " $error\n";
set_repo_state($prp, "broken");
set_repo_state($prp, 'broken', $error);
next;
}

Expand Down Expand Up @@ -5990,12 +5993,14 @@ relsynccheck:
print " building: ".scalar(keys %building).", notready: ".scalar(keys %notready).", unfinished: ".scalar(keys %unfinished)."\n";
print " took $prpchecktime seconds to check the packages\n";

my $schedulerstate;
my $schedulerdetails;
if (keys %building) {
set_repo_state($prp, "building");
$schedulerstate = 'building';
} elsif (keys %unfinished) {
set_repo_state($prp, "blocked");
$schedulerstate = 'blocked';
} else {
set_repo_state($prp, "finished");
$schedulerstate = 'finished';
}

# we always publish kiwi...
Expand Down Expand Up @@ -6026,6 +6031,7 @@ relsynccheck:
mkdir_p("$reporoot/$prp/$myarch");
$publisherror = prpfinished($prp, \@packs, \%pubenabled, $bconf, $prpsearchpath{$prp});
writestr("$reporoot/$prp/$myarch/:repodone", undef, $repodonestate) unless $publisherror || %unfinished;
$schedulerdetails = $publisherror if $publisherror;
} else {
print " publishing is disabled\n";
writestr("$reporoot/$prp/$myarch/:repodone", undef, "disabled");
Expand All @@ -6048,6 +6054,8 @@ relsynccheck:
unlink("$reporoot/$prp/$myarch/:repodone");
}

set_repo_state($prp, $schedulerstate, $schedulerdetails);

if (%unfinished) {
$prpunfinished{$prp} = scalar(keys %unfinished);
} else {
Expand Down

0 comments on commit 8271982

Please sign in to comment.