From ce3c26e00429b7c96137385d459057af4ccbf3b7 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 20 Apr 2017 23:32:23 -0400 Subject: [PATCH] mds: fix mantle script to not fail for last rank Fixes: http://tracker.ceph.com/issues/19589 Signed-off-by: Patrick Donnelly --- src/mds/balancers/greedyspill.lua | 47 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/mds/balancers/greedyspill.lua b/src/mds/balancers/greedyspill.lua index c3e38fa4a14d..20576cdb8038 100644 --- a/src/mds/balancers/greedyspill.lua +++ b/src/mds/balancers/greedyspill.lua @@ -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 -- 2.47.3