2955: Moved logic to clean jobs table from crunch-dispatch into a standalone
[arvados.git] / services / api / script / crunch-dispatch.rb
index f49f21b04c1e529f40f5368f252d02938d33c18d..87acb651a4347c2900689c296eb20b108f35e213 100755 (executable)
@@ -41,24 +41,6 @@ class Dispatcher
     return act_as_system_user
   end
 
-  def refresh_running
-    Job.running.each do |jobrecord|
-      if !@running[jobrecord.uuid]
-        f = Log.filter(["object_uuid", "=", jobrecord.uuid]).limit(1).order("created_at desc").results.first
-        if (Time.now - f.created_at) > 300
-          # job is marked running, but not known to crunch-dispatcher, and
-          # hasn't produced any log entries for 5 minutes, so mark it as failed.
-          jobrecord.running = false
-          jobrecord.finished_at ||= Time.now
-          if jobrecord.success.nil?
-            jobrecord.success = false
-          end
-          jobrecord.save!
-        end
-      end
-    end
-  end
-
   def refresh_todo
     @todo = Job.queue.select do |j| j.repository end
     @todo_pipelines = PipelineInstance.queue
@@ -406,7 +388,6 @@ class Dispatcher
           end
         end
       else
-        refresh_running unless did_recently(:refresh_running, 60.0)
         refresh_todo unless did_recently(:refresh_todo, 1.0)
         update_node_status
         unless @todo.empty? or did_recently(:start_jobs, 1.0) or $signal[:term]