[ARVADOS] updated: 37f4e715acc84ddf47938c5a42bd86edf3cf05e1

git at public.curoverse.com git at public.curoverse.com
Wed Sep 24 15:25:30 EDT 2014


Summary of changes:
 services/api/script/crunch-dispatch.rb | 39 ++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 7 deletions(-)

       via  37f4e715acc84ddf47938c5a42bd86edf3cf05e1 (commit)
      from  10caf4bc580e7f1646373ef9c1eda1579f0eb52d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 37f4e715acc84ddf47938c5a42bd86edf3cf05e1
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Sep 24 15:24:55 2014 -0400

    2881: Fixup by restoring older SLURM output parsing.

diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index 4573f2b..5163e83 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -61,18 +61,43 @@ class Dispatcher
     end
   end
 
+  def each_slurm_line(cmd, outfmt, max_fields=nil)
+    max_fields ||= outfmt.split(":").size
+    max_fields += 1  # To accommodate the node field we add
+    @@slurm_version ||= Gem::Version.new(`sinfo --version`.match(/\b[\d\.]+\b/)[0])
+    if Gem::Version.new('2.3') <= @@slurm_version
+      `#{cmd} --noheader -o '%n:#{outfmt}'`.each_line do |line|
+        yield line.chomp.split(":", max_fields)
+      end
+    else
+      # Expand rows with hostname ranges (like "foo[1-3,5,9-12]:idle")
+      # 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]+)\]$/)
+          tokens.shift
+          re[2].split(",").each do |range|
+            range = range.split("-").collect(&:to_i)
+            (range[0]..range[-1]).each do |n|
+              yield [re[1] + n.to_s] + tokens
+            end
+          end
+        else
+          yield tokens
+        end
+      end
+    end
+  end
+
   def slurm_status
     slurm_nodes = {}
-    `sinfo --noheader -o %n:%t`.each_line do |sinfo_line|
-      hostname, state = sinfo_line.chomp.split(":", 2)
+    each_slurm_line("sinfo", "%t") do |hostname, state|
       state.sub!(/\W+$/, "")
-      state = "down" unless %w(idle alloc down).include? state
+      state = "down" unless %w(idle alloc down).include?(state)
       slurm_nodes[hostname] = {state: state, job: nil}
     end
-    `squeue --noheader -o %n:%j`.each_line do |squeue_line|
-      hostname, job_uuid = squeue_line.chomp.split(":", 2)
-      next unless slurm_nodes[hostname]
-      slurm_nodes[hostname][:job] = job_uuid
+    each_slurm_line("squeue", "%j") do |hostname, job_uuid|
+      slurm_nodes[hostname][:job] = job_uuid if slurm_nodes[hostname]
     end
     slurm_nodes
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list