]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix mantle script to not fail for last rank 14704/head
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Apr 2017 03:32:23 +0000 (23:32 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Apr 2017 14:27:41 +0000 (10:27 -0400)
Fixes: http://tracker.ceph.com/issues/19589
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/balancers/greedyspill.lua

index c3e38fa4a14d6003e8698cfa2feb37f0a2b12d1a..20576cdb803850ef331238f3e93013054111763d 100644 (file)
@@ -1,48 +1,49 @@
-metrics = {"auth.meta_load", "all.meta_load", "req_rate", "queue_len", "cpu_load_avg"}
+local metrics = {"auth.meta_load", "all.meta_load", "req_rate", "queue_len", "cpu_load_avg"}
 
 -- Metric for balancing is the workload; also dumps metrics
-function mds_load()
-  for i=0, #mds do
-    s = "MDS"..i..": < "
-    for j=1, #metrics do
-      s = s..metrics[j].."="..mds[i][metrics[j]].." "
+local function mds_load()
+  for rank, mds in pairs(mds) do
+    local s = "MDS"..rank..": < "
+    for _, metric in ipairs(metrics) do
+      s = s..metric.."="..mds[metric].." "
     end
-    mds[i]["load"] = mds[i]["all.meta_load"]
-    BAL_LOG(0, s.."> load="..mds[i]["load"])
+    mds.load = mds["all.meta_load"]
+    BAL_LOG(5, s.."> load="..mds.load)
   end
 end
 
 -- Shed load when you have load and your neighbor doesn't
-function when()
+local function when()
+  if not mds[whoami+1] then
+    -- i'm the last rank
+    BAL_LOG(5, "when: not migrating! I am the last rank, nothing to spill to.");
+    return false
+  end
   my_load = mds[whoami]["load"]
   his_load = mds[whoami+1]["load"]
   if my_load > 0.01 and his_load < 0.01 then
-    BAL_LOG(2, "when: migrating! my_load="..my_load.." hisload="..his_load)
+    BAL_LOG(5, "when: migrating! my_load="..my_load.." hisload="..his_load)
     return true
   end
-  BAL_LOG(2, "when: not migrating! my_load="..my_load.." hisload="..his_load)
+  BAL_LOG(5, "when: not migrating! my_load="..my_load.." hisload="..his_load)
   return false
 end
 
 -- Shed half your load to your neighbor
 -- neighbor=whoami+2 because Lua tables are indexed starting at 1
-function where()
-  targets = {}
-  for i=1, #mds+1 do
-    targets[i] = 0
-  end
-
-  targets[whoami+2] = mds[whoami]["load"]/2
+local function where(targets)
+  targets[whoami+1] = mds[whoami]["load"]/2
   return targets
 end
 
+local targets = {}
+for rank in pairs(mds) do
+  targets[rank] = 0
+end
+
 mds_load()
 if when() then
-  return where()
+  where(targets)
 end
 
-targets = {}
-for i=1, #mds+1 do
-  targets[i] = 0
-end
 return targets