X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c8ad3a2a0f27964eff5d5c2d845afab728836473..195b23ed7fd0c6261d0a945a9f0e541d78a0648e:/sdk/cli/bin/crunch-job?ds=sidebyside diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index 3dd1627a7d..f56099d1ad 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -1037,12 +1037,16 @@ sub check_refresh_wanted my $Job2 = $arv->{'jobs'}->{'get'}->execute('uuid' => $jobspec); for my $attr ('cancelled_at', 'cancelled_by_user_uuid', - 'cancelled_by_client_uuid') { + 'cancelled_by_client_uuid', + 'state') { $Job->{$attr} = $Job2->{$attr}; } - if ($Job->{'cancelled_at'}) { - Log (undef, "Job cancelled at " . $Job->{cancelled_at} . - " by user " . $Job->{cancelled_by_user_uuid}); + if ($Job->{'state'} ne "Running") { + if ($Job->{'state'} eq "Cancelled") { + Log (undef, "Job cancelled at " . $Job->{'cancelled_at'} . " by user " . $Job->{'cancelled_by_user_uuid'}); + } else { + Log (undef, "Job state unexpectedly changed to " . $Job->{'state'}); + } $main::success = 0; $main::please_freeze = 1; } @@ -1340,9 +1344,8 @@ sub croak sub cleanup { return if !$job_has_uuid; - if ($Job->{'cancelled_at'}) { - $Job->update_attributes('state' => 'Cancelled', - 'finished_at' => scalar gmtime); + if ($Job->{'state'} eq 'Cancelled') { + $Job->update_attributes('finished_at' => scalar gmtime); } else { $Job->update_attributes('state' => 'Failed'); }