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 ...@@ -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.Concurrent (threadDelay)
import Control.Exception (bracket) import Control.Exception (bracket)
...@@ -90,7 +94,8 @@ options = ...@@ -90,7 +94,8 @@ options =
we find a valid solution or we exceed the maximum depth. 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 -> Int -- ^ Remaining length
-> Bool -- ^ Allow disk moves -> Bool -- ^ Allow disk moves
-> Bool -- ^ Allow instance moves -> Bool -- ^ Allow instance moves
...@@ -103,7 +108,7 @@ iterateDepth :: Cluster.Table -- ^ The starting table ...@@ -103,7 +108,7 @@ iterateDepth :: Cluster.Table -- ^ The starting table
-> Bool -- ^ Enable evacuation mode -> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table -> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands -- 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 = cmd_strs min_score mg_limit min_gain evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl let Cluster.Table ini_nl ini_il _ _ = ini_tbl
allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score 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 ...@@ -121,9 +126,10 @@ iterateDepth ini_tbl max_rounds disk_moves inst_moves nmlen imlen
nmlen imlen cur_plc fin_plc_len nmlen imlen cur_plc fin_plc_len
afn = Cluster.involvedNodes ini_il cur_plc afn = Cluster.involvedNodes ini_il cur_plc
upd_cmd_strs = (afn, idx, move, cmds):cmd_strs upd_cmd_strs = (afn, idx, move, cmds):cmd_strs
putStrLn sol_line when printmove $ do
hFlush stdout putStrLn sol_line
iterateDepth fin_tbl max_rounds disk_moves inst_moves hFlush stdout
iterateDepth printmove fin_tbl max_rounds disk_moves inst_moves
nmlen imlen upd_cmd_strs min_score nmlen imlen upd_cmd_strs min_score
mg_limit min_gain evac_mode mg_limit min_gain evac_mode
Nothing -> return (ini_tbl, cmd_strs) Nothing -> return (ini_tbl, cmd_strs)
...@@ -382,7 +388,7 @@ main opts args = do ...@@ -382,7 +388,7 @@ main opts args = do
let imlen = maximum . map (length . Instance.alias) $ Container.elems il let imlen = maximum . map (length . Instance.alias) $ Container.elems il
nmlen = maximum . map (length . Node.alias) $ Container.elems nl 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) (optDiskMoves opts)
(optInstMoves opts) (optInstMoves opts)
nmlen imlen [] min_cv 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