X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/09a2e88c51e5432e607f2a38466e55b4ba15e887..c01ce0788adade520dc825152685aee0449a7da4:/services/api/lib/crunch_dispatch.rb diff --git a/services/api/lib/crunch_dispatch.rb b/services/api/lib/crunch_dispatch.rb index 83cd1b9295..1b1df36013 100644 --- a/services/api/lib/crunch_dispatch.rb +++ b/services/api/lib/crunch_dispatch.rb @@ -73,7 +73,7 @@ class CrunchDispatch # into multiple rows with one hostname each. `#{cmd} --noheader -o '%N:#{outfmt}'`.each_line do |line| tokens = line.chomp.split(":", max_fields) - if (re = tokens[0].match /^(.*?)\[([-,\d]+)\]$/) + if (re = tokens[0].match(/^(.*?)\[([-,\d]+)\]$/)) tokens.shift re[2].split(",").each do |range| range = range.split("-").collect(&:to_i) @@ -105,7 +105,7 @@ class CrunchDispatch end def update_node_status - return unless Server::Application.config.crunch_job_wrapper.to_s.match /^slurm/ + return unless Server::Application.config.crunch_job_wrapper.to_s.match(/^slurm/) slurm_status.each_pair do |hostname, slurmdata| next if @node_state[hostname] == slurmdata begin @@ -169,7 +169,25 @@ class CrunchDispatch end usable_nodes << node if usable_nodes.count >= min_node_count - return usable_nodes.map { |node| node.hostname } + hostnames = usable_nodes.map(&:hostname) + log_nodes = usable_nodes.map do |n| + "#{n.hostname} #{n.uuid} #{n.properties.to_json}" + end + log_job = "#{job.uuid} #{job.runtime_constraints}" + log_text = "dispatching job #{log_job} to #{log_nodes.join(", ")}" + $stderr.puts log_text + begin + act_as_system_user do + Log.new(object_uuid: job.uuid, + event_type: 'dispatch', + owner_uuid: system_user_uuid, + summary: "dispatching to #{hostnames.join(", ")}", + properties: {'text' => log_text}).save! + end + rescue => e + $stderr.puts "dispatch: log.create failed: #{e}" + end + return hostnames end end nil @@ -204,8 +222,8 @@ class CrunchDispatch owner_uuid: job.owner_uuid, summary: message, properties: {"text" => message}).save! - rescue - $stderr.puts "dispatch: log.create failed" + rescue => e + $stderr.puts "dispatch: log.create failed: #{e}" end if not skip_lock and not have_job_lock?(job) @@ -512,8 +530,6 @@ class CrunchDispatch def read_pipes @running.each do |job_uuid, j| - job = j[:job] - now = Time.now if now > j[:log_throttle_reset_time] # It has been more than throttle_period seconds since the last