Commit 2e28ac32 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement evacuation mode in hbal



This mode restricts the list of instances to be moved to the instances
living on the offline (and drained) nodes.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
parent f0f21ec4
......@@ -460,12 +460,20 @@ doNextBalance ini_tbl max_rounds min_score =
tryBalance :: Table -- ^ The starting table
-> Bool -- ^ Allow disk moves
-> Bool -- ^ Only evacuate moves
-> Maybe Table -- ^ The resulting table and commands
tryBalance ini_tbl disk_moves =
tryBalance ini_tbl disk_moves evac_mode =
let Table ini_nl ini_il ini_cv _ = ini_tbl
all_inst = Container.elems ini_il
all_inst' = if evac_mode
then let bad_nodes = map Node.idx . filter Node.offline $
Container.elems ini_nl
in filter (\e -> Instance.sNode e `elem` bad_nodes ||
Instance.pNode e `elem` bad_nodes)
all_inst
else all_inst
reloc_inst = filter (\e -> Instance.sNode e /= Node.noSecondary)
all_inst
all_inst'
node_idx = map Node.idx . filter (not . Node.offline) $
Container.elems ini_nl
fin_tbl = checkMove node_idx disk_moves ini_tbl reloc_inst
......
......@@ -60,6 +60,7 @@ options =
, oPrintCommands
, oOneline
, oDataFile
, oEvacMode
, oRapiMaster
, oLuxiSocket
, oExecJobs
......@@ -89,14 +90,15 @@ iterateDepth :: Cluster.Table -- ^ The starting table
-> [MoveJob] -- ^ Current command list
-> Bool -- ^ Whether to be silent
-> Score -- ^ Score at which to stop
-> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands
iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
cmd_strs oneline min_score =
cmd_strs oneline min_score evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl
allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score
m_fin_tbl = if allowed_next
then Cluster.tryBalance ini_tbl disk_moves
then Cluster.tryBalance ini_tbl disk_moves evac_mode
else Nothing
in
case m_fin_tbl of
......@@ -115,6 +117,7 @@ iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
hFlush stdout
iterateDepth fin_tbl max_rounds disk_moves
nmlen imlen upd_cmd_strs oneline min_score
evac_mode
Nothing -> return (ini_tbl, cmd_strs)
-- | Formats the solution for the oneline display
......@@ -270,7 +273,7 @@ main = do
(fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
(optDiskMoves opts)
nmlen imlen [] oneline min_cv
nmlen imlen [] oneline min_cv (optEvacMode opts)
let (Cluster.Table fin_nl fin_il fin_cv fin_plc) = fin_tbl
ord_plc = reverse fin_plc
sol_msg = if null fin_plc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment