3168: Instead of crashing using save! log an error and go to the next job.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 26 Sep 2014 13:47:52 +0000 (09:47 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 26 Sep 2014 13:47:52 +0000 (09:47 -0400)
services/api/script/crunch-dispatch.rb

index 53979f24a320cc134d5c1193d5333867b9f9b049..bab9f4e3e3195bd4ff4d9df8accb8aa332b407b6 100755 (executable)
@@ -237,7 +237,11 @@ class Dispatcher
       job_auth = ApiClientAuthorization.
         new(user: User.where('uuid=?', job.modified_by_user_uuid).first,
             api_client_id: 0)
-      job_auth.save!
+      if not job_auth.save
+        $stderr.puts "dispatch: job_auth.save failed"
+        untake job
+        next
+      end
 
       crunch_job_bin = (ENV['CRUNCH_JOB_BIN'] || `which arv-crunch-job`.strip)
       if crunch_job_bin == ''
@@ -300,7 +304,11 @@ class Dispatcher
           # Someone has been monkeying with the job record and/or git.
           $stderr.puts "dispatch: Already a tag #{job.script_version} pointing to commit #{tag_rev} but expected commit #{job.script_version}"
           job.state = "Failed"
-          job.save!
+          if not job.save
+            $stderr.puts "dispatch: job.save failed"
+            untake job
+            next
+          end
           next
         end
       end