Skip to content

Commit

Permalink
Merge pull request #2486 from lethliel/respect_hostarch
Browse files Browse the repository at this point in the history
[backend] Respect hostarch on checkconstraintssfile and repair route
  • Loading branch information
lethliel committed Dec 20, 2016
2 parents 0527a8c + 11faedf commit e928772
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/backend/bs_repserver
Expand Up @@ -69,6 +69,7 @@ use BSSched::ProjPacks;
use BSRepServer;
use BSRepServer::BuildInfo;
use BSDispatcher::Constraints;
use BSCando;
use Build;

use strict;
Expand Down Expand Up @@ -3584,6 +3585,17 @@ sub checkconstraints {
my $prjconfconstraint = BSDispatcher::Constraints::list2struct($BSXML::constraints, \@list);
$constraints = $constraints ? BSDispatcher::Constraints::mergeconstraints($prjconfconstraint, $constraints) : $prjconfconstraint;

my %harchcando; # can the harch build an arch?
for my $harch (keys %BSCando::cando) {
for my $arch (@{$BSCando::cando{$harch}}) {
if ($arch =~ /^([^:]+):(.+)$/) {
$harchcando{"$harch/$1"} = $2;
} else {
$harchcando{"$harch/$arch"} = '';
}
}
}

my $dispatch_constraints_info = {
'project' => $projid ,
'repoid' => $repoid,
Expand All @@ -3595,6 +3607,8 @@ sub checkconstraints {
for my $workerstate (qw{idle building away dead down}) {
my @workernames = sort(grep {!/^\./} BSUtil::ls("$workersdir/$workerstate"));
for my $workername (@workernames) {
my ($harch) = split(':', $workername, 2);
next unless exists($harchcando{"$harch/$arch"});
my $worker = readxml("$workersdir/$workerstate/$workername", $BSXML::worker, 1);
next if $BSConfig::dispatch_constraint && !$BSConfig::dispatch_constraint->($dispatch_constraints_info, $worker, $constraints);
next if $constraints && BSDispatcher::Constraints::oracle($worker, $constraints) <= 0;
Expand Down
7 changes: 3 additions & 4 deletions src/backend/bs_srcserver
Expand Up @@ -5695,15 +5695,14 @@ sub hello {
####################################################################

sub getworkercap {
my ($cgi) = @_;
my ($cgi, $workerid) = @_;
my $reposerver = $BSConfig::masterdispatcher || $BSConfig::reposerver; # no need to look for partitioning here
my @args = BSRPC::args($cgi, 'workerid');
my $param = {
'uri' => "$reposerver/getworkercapabilities",
'uri' => "$reposerver/worker/$workerid",
'timeout' => 60,
};

my $worker_cap = BSWatcher::rpc($param, $BSXML::worker, @args);
my $worker_cap = BSWatcher::rpc($param, $BSXML::worker);

return($worker_cap, $BSXML::worker);
}
Expand Down

0 comments on commit e928772

Please sign in to comment.