X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1f1963df75f584d575fd440206e3ac64064cf06c..7178ac911e7b160c1348da404b5aa07b9829d3c8:/sdk/cli/bin/crunch-job diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index 83931f2c65..70f379e53f 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -848,12 +848,6 @@ release_allocation(); freeze(); my $collated_output = &collate_output(); -if ($job_has_uuid) { - $Job->update_attributes('running' => 0, - 'success' => $collated_output && $main::success, - 'finished_at' => scalar gmtime) -} - if (!$collated_output) { Log(undef, "output undef"); } @@ -880,6 +874,13 @@ else { Log (undef, "finish"); save_meta(); + +if ($job_has_uuid) { + $Job->update_attributes('running' => 0, + 'success' => $collated_output && $main::success, + 'finished_at' => scalar gmtime) +} + exit ($Job->{'success'} ? 1 : 0); @@ -1206,7 +1207,8 @@ sub collate_output Log (undef, "collate"); my ($child_out, $child_in); - my $pid = open2($child_out, $child_in, 'arv-put', '--raw'); + my $pid = open2($child_out, $child_in, 'arv-put', '--raw', + '--retries', put_retry_count()); my $joboutput; for (@jobstep) { @@ -1346,8 +1348,9 @@ sub save_meta return if $justcheckpoint; # checkpointing is not relevant post-Warehouse.pm $local_logfile->flush; - my $cmd = "arv-put --portable-data-hash --filename ''\Q$keep_logfile\E " - . quotemeta($local_logfile->filename); + my $retry_count = put_retry_count(); + my $cmd = "arv-put --portable-data-hash --retries $retry_count " . + "--filename ''\Q$keep_logfile\E " . quotemeta($local_logfile->filename); my $loglocator = `$cmd`; die "system $cmd failed: $?" if $?; chomp($loglocator); @@ -1493,6 +1496,20 @@ sub find_docker_image { } } +sub put_retry_count { + # Calculate a --retries argument for arv-put that will have it try + # approximately as long as this Job has been running. + my $stoptime = shift || time; + my $starttime = $jobstep[0]->{starttime}; + my $timediff = defined($starttime) ? ($stoptime - $starttime) : 1; + my $retries = 0; + while ($timediff >= 2) { + $retries++; + $timediff /= 2; + } + return ($retries > 3) ? $retries : 3; +} + __DATA__ #!/usr/bin/perl