bug fixes
This commit is contained in:
@@ -55,21 +55,30 @@ sub summary {
|
|||||||
|
|
||||||
Find the best status and log it into the job's C<status> and C<log> slots.
|
Find the best status and log it into the job's C<status> and C<log> slots.
|
||||||
|
|
||||||
|
The process is to track back from the last worker, ignoring user workers, and
|
||||||
|
find the best status (out of done, defer, error) within the last phase run.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub finalise_status {
|
sub finalise_status {
|
||||||
my $job = shift;
|
my $job = shift;
|
||||||
my $max_level = Status->error()->level;
|
|
||||||
# use DDP; p $job->_statuslist;
|
# use DDP; p $job->_statuslist;
|
||||||
|
|
||||||
# fallback
|
# fallback
|
||||||
$job->status('error');
|
$job->status('error');
|
||||||
$job->log('failed to report from any worker!');
|
$job->log('failed to report from any worker!');
|
||||||
|
|
||||||
foreach my $status (@{ $job->_statuslist }) {
|
my $phase = undef;
|
||||||
|
my $max_level = Status->error()->level;
|
||||||
|
|
||||||
|
foreach my $status (reverse @{ $job->_statuslist }) {
|
||||||
next unless $status->phase
|
next unless $status->phase
|
||||||
and $status->phase =~ m/^(?:check|early|main)$/;
|
and $status->phase =~ m/^(?:check|early|main)$/;
|
||||||
if ($status->level >= $max_level) {
|
|
||||||
|
$phase ||= $status->phase;
|
||||||
|
last if $status->phase ne $phase;
|
||||||
|
|
||||||
|
if ($status->level > $max_level) {
|
||||||
$job->status( $status->status );
|
$job->status( $status->status );
|
||||||
$job->log( $status->log );
|
$job->log( $status->log );
|
||||||
$max_level = $status->level;
|
$max_level = $status->level;
|
||||||
@@ -97,7 +106,7 @@ sub check_passed {
|
|||||||
|
|
||||||
=head2 namespace_passed( \%workerconf )
|
=head2 namespace_passed( \%workerconf )
|
||||||
|
|
||||||
Returns true when, for the namespace specified in the passed configuration, a
|
Returns true when, for the namespace specified in the given configuration, a
|
||||||
worker of a higher priority level has already succeeded.
|
worker of a higher priority level has already succeeded.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
@@ -109,7 +118,7 @@ sub namespace_passed {
|
|||||||
foreach my $status (@{ $job->_statuslist }) {
|
foreach my $status (@{ $job->_statuslist }) {
|
||||||
next unless ($status->phase and $status->phase eq $workerconf->{phase})
|
next unless ($status->phase and $status->phase eq $workerconf->{phase})
|
||||||
and ($workerconf->{namespace} eq $job->_last_namespace)
|
and ($workerconf->{namespace} eq $job->_last_namespace)
|
||||||
and ($workerconf->{priority} > $job->_last_priority);
|
and ($workerconf->{priority} < $job->_last_priority);
|
||||||
return true if $status->is_ok;
|
return true if $status->is_ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,8 +136,12 @@ Pass the name of the phase being entered.
|
|||||||
|
|
||||||
sub enter_phase {
|
sub enter_phase {
|
||||||
my ($job, $phase) = @_;
|
my ($job, $phase) = @_;
|
||||||
|
|
||||||
$job->_current_phase( $phase );
|
$job->_current_phase( $phase );
|
||||||
debug "=> running workers for phase: $phase";
|
debug "=> running workers for phase: $phase";
|
||||||
|
|
||||||
|
$job->_last_namespace( undef );
|
||||||
|
$job->_last_priority( undef );
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 add_status
|
=head2 add_status
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ register 'register_worker' => sub {
|
|||||||
my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef);
|
my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef);
|
||||||
my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef);
|
my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef);
|
||||||
|
|
||||||
return $job->add_status( Status->defer('worker is not applicable to this device') )
|
return $job->add_status( Status->noop('worker not applicable to this device') )
|
||||||
if ($no and check_acl_no($job->device, $no))
|
if ($no and check_acl_no($job->device, $no))
|
||||||
or ($only and not check_acl_only($job->device, $only));
|
or ($only and not check_acl_only($job->device, $only));
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ register 'register_worker' => sub {
|
|||||||
next if exists $stanza->{driver} and exists $workerconf->{driver}
|
next if exists $stanza->{driver} and exists $workerconf->{driver}
|
||||||
and (($stanza->{driver} || '') ne ($workerconf->{driver} || ''));
|
and (($stanza->{driver} || '') ne ($workerconf->{driver} || ''));
|
||||||
|
|
||||||
|
# filter here rather than in Runner as runner does not know namespace
|
||||||
next if exists $stanza->{action}
|
next if exists $stanza->{action}
|
||||||
and not _find_matchaction($workerconf, lc($stanza->{action}));
|
and not _find_matchaction($workerconf, lc($stanza->{action}));
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ register 'register_worker' => sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# per-device action but no device creds available
|
# per-device action but no device creds available
|
||||||
return $job->add_status( Status->defer('deferred job with no device creds') )
|
return $job->add_status( Status->noop('worker driver or action not applicable') )
|
||||||
if 0 == scalar @newuserconf;
|
if 0 == scalar @newuserconf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user