Skip to content

Commit

Permalink
Merge pull request #1790 from b1-systems/projectcopy_backport2.6
Browse files Browse the repository at this point in the history
[backend]Projectcopy backport2.6
  • Loading branch information
adrianschroeter committed May 18, 2016
2 parents 53ca524 + bac97ed commit e7213dc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backend/bs_repserver
Expand Up @@ -2162,8 +2162,8 @@ sub forwardevent {
if ($type eq 'badhost') {
$repoid = $cgi->{'repository'} if exists $cgi->{'repository'};
$arch = $cgi->{'arch'} if exists $cgi->{'arch'};
$job = $cgi->{'job'} if exists $cgi->{'job'};
}
$job = $cgi->{'job'} if exists($cgi->{'job'}) && ($type eq 'badhost' || $type eq 'suspendproject');
# hack: mis-use job to transfer wipe target
if ($type eq 'wipe' && $cgi->{'wipe'}) {
$job = join(',', @{$cgi->{'wipe'}});
Expand Down
37 changes: 36 additions & 1 deletion src/backend/bs_sched
Expand Up @@ -7086,6 +7086,10 @@ sub event_package {
my $packid = $ev->{'package'};
push @{$fetchprojpacks->{$projid}}, $packid;
$deepcheck->{$projid} = 1 if !defined $packid;
if (!defined($packid) && $ectx->{'gctx'}->{'projsuspended'}->{$projid}) {
print "resuming project $projid\n";
delete $ectx->{'gctx'}->{'projsuspended'}->{$projid};
}
}

sub event_project {
Expand Down Expand Up @@ -7354,6 +7358,8 @@ sub event_exit {
$schedstate->{'lookat_oob'} = $ectx->{'lookat_med'};
$schedstate->{'lookat_oobhigh'} = $ectx->{'lookat_high'};
$schedstate->{'prpfinished'} = \%prpfinished;
my $gctx = $ectx->{'gctx'};
$schedstate->{'projsuspended'} = $gctx->{'projsuspended'} if %{$gctx->{'projsuspended'} || {}};
$schedstate->{'globalnotready'} = \%prpnotready;
$schedstate->{'fetchprojpacks'} = $ectx->{'fetchprojpacks'} if %{$ectx->{'fetchprojpacks'} || {}};
$schedstate->{'delayedfetchprojpacks'} = $ectx->{'delayedfetchprojpacks'};
Expand Down Expand Up @@ -7407,6 +7413,23 @@ sub event_configuration {
BSConfiguration::update_from_configuration();
}

sub event_suspendproject {
my ($ectx, $ev) = @_;
my $projid = $ev->{'project'};
my $gctx = $ectx->{'gctx'};
return unless $ev->{'job'};
print "suspending project $projid: $ev->{'job'}\n";
$gctx->{'projsuspended'}->{$projid} = $ev->{'job'};
# try to set the repo state right away
my $projpacks = $gctx->{'projpacks'};
my $proj = $projpacks->{$projid};
return unless $proj;
for my $repo (@{$proj->{'repository'} || []}) {
next unless grep {$_ eq $gctx->{'arch'}} @{$repo->{'arch'} || []};
set_repo_state("$projid/$repo->{'name'}", 'blocked', $ev->{'job'});
}
}

my %event_handlers = (
'built' => \&event_built,
'uploadbuild' => \&event_built,
Expand Down Expand Up @@ -7434,6 +7457,7 @@ my %event_handlers = (
'dumpstate' => \&event_exit,
'useforbuild' => \&event_useforbuild,
'configuration' => \&event_configuration,
'suspendproject' => \&event_suspendproject,
);


Expand Down Expand Up @@ -7694,6 +7718,7 @@ my %changed_high;
my %changed_dirty;
my %lastcheck;
my %delayedfetchprojpacks;
my %projsuspended = {};

my %lookat_next; # not so important, next series
my @lookat_low; # not so important
Expand Down Expand Up @@ -7780,6 +7805,10 @@ if (!$testprojid && -s "$rundir/bs_sched.$myarch.state") {
$delayedfetchprojpacks{$projid} = $olddelayedfetchprojpacks->{$projid} if $olddelayedfetchprojpacks->{$projid};
}

# update projsuspended hash
my $oldprojsuspended = $schedstate->{'projsuspended'} || {};
%projsuspended = %$oldprojsuspended;

# use old start values
if ($schedstate->{'watchremote_start'}) {
%watchremote_start = %{$schedstate->{'watchremote_start'}};
Expand Down Expand Up @@ -7928,6 +7957,7 @@ my $gctx = {

'nextmed' => \%nextmed,
'iswaiting' => \%iswaiting,
'projsuspended' => \%projsuspended,
};

##
Expand Down Expand Up @@ -8047,7 +8077,7 @@ NEXTPRP:
if (@events > 1) {
# sort events a bit, exit events go first ;-)
# uploadbuild events must go last
my %evprio = ('exit' => -1, 'exitcomplete' => -1, 'restart' => -1, 'uploadbuild' => 1);
my %evprio = ('exit' => -2, 'exitcomplete' => -2, 'restart' => -2, 'suspendproject' => -1, 'uploadbuild' => 1);
@events = sort {($evprio{$a->{'type'}} || 0) <=> ($evprio{$b->{'type'}} || 0) ||
$a->{'type'} cmp $b->{'type'} ||
($a->{'project'} || '') cmp ($b->{'project'} || '') ||
Expand Down Expand Up @@ -8448,6 +8478,11 @@ NEXTPRP:
next;
}

if ($gctx->{'projsuspended'}->{$projid}) {
set_repo_state($prp, 'blocked', $gctx->{'projsuspended'}->{$projid});
next;
}

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

Expand Down
10 changes: 7 additions & 3 deletions src/backend/bs_srcserver
Expand Up @@ -253,14 +253,15 @@ sub deletenotificationpayload {
}

sub notify_repservers {
my ($type, $projid, $packid) = @_;
my ($type, $projid, $packid, $job) = @_;

my $ev = {'type' => $type, 'project' => $projid};
$ev->{'package'} = $packid if defined $packid;
addevent($ev);
addevent($ev) unless $type eq 'suspendproject';

my @args = ("type=$type", "project=$projid");
push @args, "package=$packid" if defined $packid;
push @args, "job=$job" if defined $job;
my $reposerver = $BSConfig::partitioning ? projid2reposerver($projid) : $BSConfig::reposerver;
my $param = {
'uri' => "$reposerver/event",
Expand Down Expand Up @@ -5621,6 +5622,9 @@ sub copyproject {
addrev($cgi, $projid, '_project', $files);
}

# signal start of project copy
notify_repservers('suspendproject', $projid, undef, 'copyproject in progress');

# use {} as we do not want to copy project linked packages
my @pkgs = findpackages($oprojid, {});
delete $cgi->{'servicemark'}; # just in case...
Expand Down Expand Up @@ -5757,7 +5761,7 @@ sub copyproject {
}
# check all packages in project
notify_repservers('package', $projid);
return $BSStdServer::return_ok;
return $BSStdServer::return_ok; # also resumes the project
}

# we're going to auto-update a link. this means we must also
Expand Down

0 comments on commit e7213dc

Please sign in to comment.