clean-up "force junking": do not prepare a host to be untainted with the

"wrong" port, but instead, create a pseudo-path that is just there to run
junk (will be logged as junk-proxy)

fix a bug in the task handling host locking (no next task -> unlock, duh).

do not log multiple K for several ports on the same basepkgpath.
This commit is contained in:
espie 2015-07-02 08:04:22 +00:00
parent e9d1a5b12d
commit 7c34de513e
5 changed files with 95 additions and 17 deletions

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: HostProperties.pm,v 1.13 2015/06/23 09:01:56 espie Exp $
# $OpenBSD: HostProperties.pm,v 1.14 2015/07/02 08:04:22 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -120,7 +120,7 @@ sub taint
return;
}
my $t1 = $self->{tainted};
if (!defined $t1 || $v->{forcejunk}) {
if (!defined $t1) {
$self->{tainted} = $t2;
$self->{tainted_source} = $v->fullpkgpath;
return;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Port.pm,v 1.165 2015/06/23 09:01:56 espie Exp $
# $OpenBSD: Port.pm,v 1.166 2015/07/02 08:04:22 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -27,7 +27,7 @@ sub want
# job is normally attached to core, unless it's not attached,
# and then we pass it as an extra parameter
$job //= $core->job;
return 2 if $job->{v}{forcejunk};
return 2 if $job->{v}->forcejunk;
# XXX let's wipe the slates at the start of the first tagged
# job, as we don't know the exact state of the host.
return 2 if $job->{v}{info}->has_property('tag') &&
@ -347,7 +347,7 @@ sub finalize
my $task = $job->{tasks}[0];
# XXX if we didn't lock at the entrance, we locked here.
$job->{locked} = 1;
if ($core->{status} != 0 || defined $task && !$task->is_serialized) {
if ($core->{status} != 0 || !defined $task || !$task->is_serialized) {
$self->junk_unlock($core);
}
$self->SUPER::finalize($core);
@ -1118,6 +1118,21 @@ sub new
return $job;
}
sub new_junk_only
{
my $class = shift;
my ($log, $fh, $v, $lock, $builder, $special, $core,
$endcode) = @_;
my $job = $class->SUPER::new(@_);
my $fh2 = $job->{builder}->logger->append("junk");
print $fh2 "$$@", CORE::time(), ": ", $core->hostname,
": forced junking -> $job->{path}\n";
$job->add_tasks(DPB::Port::TaskFactory->create('junk'));
return $job;
}
sub add_normal_tasks
{
my ($self, $dontclean, $core) = @_;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: PkgPath.pm,v 1.50 2015/06/11 08:42:38 espie Exp $
# $OpenBSD: PkgPath.pm,v 1.51 2015/07/02 08:04:22 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -35,6 +35,11 @@ sub init
$self->{has} = 5;
}
sub forcejunk
{
return 0;
}
sub path
{
my $self = shift;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: PortBuilder.pm,v 1.71 2015/05/12 19:48:29 espie Exp $
# $OpenBSD: PortBuilder.pm,v 1.72 2015/07/02 08:04:22 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -252,6 +252,27 @@ sub build
$job->set_watch($self->logger, $v);
}
sub force_junk
{
my ($self, $v, $core, $final_sub) = @_;
my $start = time();
my $log = $self->logger->log_pkgpath($v);
my $fh = $self->logger->open('>>', $log);
print $fh ">>> Force junking on ", $core->hostname;
if (defined $core->{user}) {
print $fh " as ", $core->{user}->user, " ";
}
my $job;
$job = DPB::Job::Port->new_junk_only($log, $fh, $v, undef, $self,
0,$core,
sub {
close($fh);
&$final_sub($job->{failed});
$core->mark_ready;
});
$core->start_job($job, $v);
}
sub test
{
my ($self, $v, $core, $lock, $final_sub) = @_;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Build.pm,v 1.15 2015/06/23 14:22:50 espie Exp $
# $OpenBSD: Build.pm,v 1.16 2015/07/02 08:04:22 espie Exp $
#
# Copyright (c) 2010-2013 Marc Espie <espie@openbsd.org>
#
@ -44,6 +44,7 @@ sub preempt_core
# so mismatches holds a copy of stuff that's still there.
$self->{mismatches} = [];
$self->{tag_mismatches} = [];
$self->{klogged} = {};
return 0;
}
@ -60,9 +61,17 @@ sub can_start_build
# fail abysmally if there's no junking going on
my $reason = $core->prop->taint_incompatible($v);
if (defined $reason) {
$self->log('K', $v, " ".$core->hostname." ".$reason);
push(@{$self->{tag_mismatches}}, $v);
return 0;
if (!$self->{klogged}{$v->pkgpath}) {
$self->log('K', $v, " ".$core->hostname." ".$reason);
$self->{klogged}{$v->pkgpath} = 1;
}
# if ($self->can_be_junked($v, $core)) {
# $self->force_junk($core);
# return 1;
# } else {
push(@{$self->{tag_mismatches}}, $v);
return 0;
# }
}
# keep affinity mismatches for later
if (defined $v->{affinity} && !$core->matches_affinity($v)) {
@ -158,12 +167,8 @@ sub recheck_mismatches
# to fix, it requires a "pseudo" junk first
# to untaint the host, THEN we can try building.
next unless $self->can_be_junked($v, $core);
$v->{forcejunk} = 1;
if ($self->lock_and_start_build($core, $v)) {
$self->log('C', $v);
return 1;
}
delete $v->{forcejunk};
$self->force_junk($core);
return 1;
}
}
# let's make sure we don't have something else first
@ -303,6 +308,18 @@ sub start_build
});
}
sub force_junk
{
my ($self, $core) = @_;
my $v = JunkPath->new;
$self->log('C', $v, " ".$core->hostname);
$self->{builder}->force_junk($v, $core,
sub {
my $fail = shift;
$self->log($fail ? 'E': 'B' , $v, " ".$core->hostname);
});
}
sub end_build
{
my ($self, $v) = @_;
@ -323,4 +340,24 @@ sub add
$self->SUPER::add($v);
}
package JunkPath;
our @ISA = qw(DPB::PkgPath);
sub new
{
my $class = shift;
my $v = bless {}, $class;
DPB::PortInfo->new($v);
return $v;
}
sub fullpkgpath
{
return "junk-proxy";
}
sub forcejunk
{
return 1;
}
1;