Merge branch 'master' into 3859-api-job-lock-method
authorPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 26 Sep 2014 15:02:06 +0000 (11:02 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 26 Sep 2014 15:02:06 +0000 (11:02 -0400)
Conflicts:
services/api/script/crunch-dispatch.rb

1  2 
services/api/app/controllers/arvados/v1/jobs_controller.rb
services/api/app/models/job.rb
services/api/script/crunch-dispatch.rb

Simple merge
index c152841ba6ee8a2606d05702c66f31e2ed687319,00144d3da470a98d3bb67cf49dfd6fa2427ec4c7..e54105d53b2c7220c2d62d7ef4b3b88c8a40c52f
@@@ -419,18 -443,15 +443,17 @@@ class Dispatche
      end
  
      # Wait the thread (returns a Process::Status)
 -    exit_status = j_done[:wait_thr].value
 +    exit_status = j_done[:wait_thr].value.exitstatus
  
      jobrecord = Job.find_by_uuid(job_done.uuid)
-     if exit_status != 75 and jobrecord.started_at
-       # Clean up state fields in case crunch-job exited without
-       # putting the job in a suitable "finished" state.
-       jobrecord.running = false
-       jobrecord.finished_at ||= Time.now
-       if jobrecord.success.nil?
-         jobrecord.success = false
 -    if exit_status.to_i != 75 and jobrecord.state == "Running"
++    if exit_status != 75 and jobrecord.state == "Running"
+       # crunch-job did not return exit code 75 (see below) and left the job in
+       # the "Running" state, which means there was an unhandled error.  Fail
+       # the job.
+       jobrecord.state = "Failed"
 -      jobrecord.save!
++      if not jobrecord.save
++        $stderr.puts "dispatch: jobrecord.save failed"
 +      end
-       jobrecord.save!
      else
        # Don't fail the job if crunch-job didn't even get as far as
        # starting it. If the job failed to run due to an infrastructure