[ARVADOS] updated: e03fdab8240f07c5cb1e88b502c6d6b145e1e957

git at public.curoverse.com git at public.curoverse.com
Mon Feb 24 14:33:20 EST 2014


Summary of changes:
 services/api/script/crunch-dispatch.rb |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

       via  e03fdab8240f07c5cb1e88b502c6d6b145e1e957 (commit)
      from  d0daa6d6968ecf1a3ec7e64f7747e842f20febad (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 e03fdab8240f07c5cb1e88b502c6d6b145e1e957
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 24 11:32:41 2014 -0800

    Use %N instead of %n format and parse node ranges ourselves if slurm <2.3

diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index a23b02b..59ea162 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -40,14 +40,36 @@ class Dispatcher
     @todo = Job.queue
   end
 
+  def sinfo
+    @@slurm_version ||= Gem::Version.new(`sinfo --version`.match(/\b[\d\.]+\b/)[0])
+    if Gem::Version.new('2.3') <= @@slurm_version
+      `sinfo --noheader -o '%n:%t'`.strip
+    else
+      # Expand rows with hostname ranges (like "foo[1-3,5,9-12]:idle")
+      # into multiple rows with one hostname each.
+      `sinfo --noheader -o '%N:%t'`.split("\n").collect do |line|
+        tokens = line.split ":"
+        if (re = tokens[0].match /^(.*?)\[([-,\d]+)\]$/)
+          re[2].split(",").collect do |range|
+            range = range.split("-").collect(&:to_i)
+            (range[0]..range[-1]).collect do |n|
+              [re[1] + n.to_s, tokens[1..-1]].join ":"
+            end
+          end
+        else
+          tokens.join ":"
+        end
+      end.flatten.join "\n"
+    end
+  end
+
   def update_node_status
     if Server::Application.config.crunch_job_wrapper.to_s.match /^slurm/
       @nodes_in_state = {idle: 0, alloc: 0, down: 0}
       @node_state ||= {}
       node_seen = {}
       begin
-        `sinfo --noheader -o '%n:%t'`.
-          split("\n").
+        sinfo.split("\n").
           each do |line|
           re = line.match /(\S+?):+(idle|alloc|down)/
           next if !re

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list