use Getopt::Long;
use Warehouse;
use Warehouse::Stream;
+use IPC::System::Simple qw(capturex);
$ENV{"TMPDIR"} ||= "/tmp";
$ENV{"CRUNCH_TMP"} = $ENV{"TMPDIR"} . "/crunch-job";
'qsequence' => 0,
'parameters' => {},
});
- push @jobstep, { level => 0,
- attempts => 0,
- arvados_task => $first_task,
+ push @jobstep, { 'level' => 0,
+ 'attempts' => 0,
+ 'arvados_task' => $first_task,
};
push @jobstep_todo, 0;
}
}
# give up if no nodes are succeeding
- if (!grep { $_->{node}->{losing_streak} == 0 } @slot) {
+ if (!grep { $_->{node}->{losing_streak} == 0 &&
+ $_->{node}->{hold_count} < 4 } @slot) {
my $message = "Every node has failed -- giving up on this round";
Log (undef, $message);
last THISROUND;
release_allocation();
freeze();
$Job->{'output'} = &collate_output();
-$Job->{'success'} = 0 if !$Job->{'output'};
+$Job->{'success'} = $Job->{'output'} && $success;
$Job->save;
if ($Job->{'output'})
{
- $arv->{'collections'}->{'create'}->execute('collection' => {
- 'uuid' => $Job->{'output'},
- 'manifest_text' => system("whget", $Job->{arvados_task}->{output}),
- });;
+ eval {
+ my $manifest_text = capturex("whget", $Job->{'output'});
+ $arv->{'collections'}->{'create'}->execute('collection' => {
+ 'uuid' => $Job->{'output'},
+ 'manifest_text' => $manifest_text,
+ });
+ };
+ if ($@) {
+ Log (undef, "Failed to register output manifest: $@");
+ }
}
-
Log (undef, "finish");
-$Job->{'success'} = $Job->{'output'} && $success;
-$Job->save;
-
save_meta();
exit 0;
my $exitcode = $?;
my $exitinfo = "exit $exitcode";
- $Jobstep->{arvados_task}->reload;
- my $success = $Jobstep->{arvados_task}->{success};
+ $Jobstep->{'arvados_task'}->reload;
+ my $success = $Jobstep->{'arvados_task'}->{success};
Log ($jobstepid, "child $pid on $whatslot $exitinfo success=$success");
if (!defined $success) {
# task did not indicate one way or the other --> fail
- $Jobstep->{arvados_task}->{success} = 0;
- $Jobstep->{arvados_task}->save;
+ $Jobstep->{'arvados_task'}->{success} = 0;
+ $Jobstep->{'arvados_task'}->save;
$success = 0;
}
if (!$success)
{
- --$Jobstep->{attempts} if $Jobstep->{node_fail};
+ my $no_incr_attempts;
+ $no_incr_attempts = 1 if $Jobstep->{node_fail};
+
++$thisround_failed;
++$thisround_failed_multiple if $Jobstep->{attempts} > 1;
$elapsed < 5 &&
$Jobstep->{attempts} > 1) {
Log ($jobstepid, "blaming failure on suspect node " . $slot[$proc{$pid}->{slot}]->{node}->{name} . " instead of incrementing jobstep attempts");
+ $no_incr_attempts = 1;
--$Jobstep->{attempts};
}
ban_node_by_slot($proc{$pid}->{slot});
push @jobstep_todo, $jobstepid;
Log ($jobstepid, "failure in $elapsed seconds");
+
+ --$Jobstep->{attempts} if $no_incr_attempts;
$Job->{'tasks_summary'}->{'failed'}++;
}
else
$Jobstep->{exitcode} = $exitcode;
$Jobstep->{finishtime} = time;
process_stderr ($jobstepid, $success);
- Log ($jobstepid, "output " . $Jobstep->{arvados_task}->{output});
+ Log ($jobstepid, "output " . $Jobstep->{'arvados_task'}->{output});
close $reader{$jobstepid};
delete $reader{$jobstepid};
# Load new tasks
my $newtask_list = $arv->{'job_tasks'}->{'list'}->execute(
'where' => {
- 'created_by_job_task' => $Jobstep->{arvados_task}->{uuid}
+ 'created_by_job_task' => $Jobstep->{'arvados_task'}->{uuid}
},
'order' => 'qsequence'
);
while ($jobstep[$job]->{stderr} =~ /^(.*?)\n/) {
my $line = $1;
- if ($line =~ /\+\+\+mr/) {
- last;
- }
substr $jobstep[$job]->{stderr}, 0, 1+length($line), "";
Log ($job, "stderr $line");
- if ($line =~ /srun: error: (SLURM job $ENV{SLURM_JOBID} has expired) /) {
+ if ($line =~ /srun: error: (SLURM job $ENV{SLURM_JOBID} has expired|Unable to confirm allocation for job) /) {
# whoa.
$main::please_freeze = 1;
}
my $joboutput;
for (@jobstep)
{
- next if !exists $_->{arvados_task}->{output} || $_->{exitcode} != 0;
- my $output = $_->{arvados_task}->{output};
+ next if (!exists $_->{'arvados_task'}->{output} ||
+ !$_->{'arvados_task'}->{'success'} ||
+ $_->{'exitcode'} != 0);
+ my $output = $_->{'arvados_task'}->{output};
if ($output !~ /^[0-9a-f]{32}(\+\S+)*$/)
{
$output_in_keep ||= $output =~ / [0-9a-f]{32}\S*\+K/;
# Don't start any new jobsteps on this node for 60 seconds
my $slotid = shift;
$slot[$slotid]->{node}->{hold_until} = 60 + scalar time;
+ $slot[$slotid]->{node}->{hold_count}++;
Log (undef, "backing off node " . $slot[$slotid]->{node}->{name} . " for 60 seconds");
}