Skip to content
Snippets Groups Projects
Commit e6685c53 authored by Agata Murawska's avatar Agata Murawska
Browse files

Allowing rebalance to run silently


Part of hcheck's simulation required us to silently run hbal. For that
purpose we expose iterateDepth and allow it to run silently.

Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 79eef90b
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-}
module Ganeti.HTools.Program.Hbal (main, options) where
module Ganeti.HTools.Program.Hbal
( main
, options
, iterateDepth
) where
import Control.Concurrent (threadDelay)
import Control.Exception (bracket)
......@@ -90,7 +94,8 @@ options =
we find a valid solution or we exceed the maximum depth.
-}
iterateDepth :: Cluster.Table -- ^ The starting table
iterateDepth :: Bool -- ^ Whether to print moves
-> Cluster.Table -- ^ The starting table
-> Int -- ^ Remaining length
-> Bool -- ^ Allow disk moves
-> Bool -- ^ Allow instance moves
......@@ -103,7 +108,7 @@ iterateDepth :: Cluster.Table -- ^ The starting table
-> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands
iterateDepth ini_tbl max_rounds disk_moves inst_moves nmlen imlen
iterateDepth printmove ini_tbl max_rounds disk_moves inst_moves nmlen imlen
cmd_strs min_score mg_limit min_gain evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl
allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score
......@@ -121,9 +126,10 @@ iterateDepth ini_tbl max_rounds disk_moves inst_moves nmlen imlen
nmlen imlen cur_plc fin_plc_len
afn = Cluster.involvedNodes ini_il cur_plc
upd_cmd_strs = (afn, idx, move, cmds):cmd_strs
putStrLn sol_line
hFlush stdout
iterateDepth fin_tbl max_rounds disk_moves inst_moves
when printmove $ do
putStrLn sol_line
hFlush stdout
iterateDepth printmove fin_tbl max_rounds disk_moves inst_moves
nmlen imlen upd_cmd_strs min_score
mg_limit min_gain evac_mode
Nothing -> return (ini_tbl, cmd_strs)
......@@ -382,7 +388,7 @@ main opts args = do
let imlen = maximum . map (length . Instance.alias) $ Container.elems il
nmlen = maximum . map (length . Node.alias) $ Container.elems nl
(fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
(fin_tbl, cmd_strs) <- iterateDepth True ini_tbl (optMaxLength opts)
(optDiskMoves opts)
(optInstMoves opts)
nmlen imlen [] min_cv
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment