[ARVADOS] created: 375c4ecb4d0b2c4d71df83f2d858d1ed3e78fd5d
git at public.curoverse.com
git at public.curoverse.com
Thu Sep 25 09:35:09 EDT 2014
at 375c4ecb4d0b2c4d71df83f2d858d1ed3e78fd5d (commit)
commit 375c4ecb4d0b2c4d71df83f2d858d1ed3e78fd5d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Sep 25 09:34:46 2014 -0400
3859: crunch-job use apiserver Job lock method instead of racy is_locked_by.
diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index 70f379e..6f5a699 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -282,18 +282,17 @@ my $jobmanager_id;
if ($job_has_uuid)
{
# Claim this job, and make sure nobody else does
- unless ($Job->update_attributes('is_locked_by_uuid' => $User->{'uuid'}) &&
- $Job->{'is_locked_by_uuid'} == $User->{'uuid'}) {
+ unless ($arv->{'jobs'}->{'lock'}->execute('uuid' => $Job->{'uuid'})) {
Log(undef, "Error while updating / locking job, exiting ".EX_TEMPFAIL);
- exit EX_TEMPFAIL;
- }
- $Job->update_attributes('started_at' => scalar gmtime,
- 'running' => 1,
- 'success' => undef,
- 'tasks_summary' => { 'failed' => 0,
- 'todo' => 1,
- 'running' => 0,
- 'done' => 0 });
+ exit EX_TEMPFAIL;
+ };
+
+ # lock() above sets is_locked_by_uuid and changes state to Running.
+ $Job->update_attributes(
+ 'tasks_summary' => { 'failed' => 0,
+ 'todo' => 1,
+ 'running' => 0,
+ 'done' => 0 });
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list