Skip to content
Snippets Groups Projects
Commit 544029d3 authored by Guido Trotter's avatar Guido Trotter
Browse files

HRoller: print only online nodes


To make the graphs work even when instances live on offline nodes (eg.
because we're offlining them just to exclude them, or because they have
instance still on them) we just filter them out at the end, when we're
going to print out the result.

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 777ea2c6
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,15 @@ getStats colorings = snd . foldr helper (0,"") $ algBySize colorings
| otherwise = (elsize, str ++ " LOOSE " ++ algostat el)
where elsize = (IntMap.size.snd) el
-- | Filter the output list.
-- Only online nodes are shown, and output groups which are empty after being
-- filtered are removed as well.
filterOutput :: [[Node.Node]] -> [[Node.Node]]
filterOutput l =
let onlineOnly = filter (not . Node.offline)
nonNullOnly = filter (not . null)
in nonNullOnly (map onlineOnly l)
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
......@@ -98,7 +107,6 @@ main opts args = do
maybeSaveData (optSaveCluster opts) "original" "before hroller run" ini_cdata
-- TODO: only online nodes!
-- TODO: filter by node group
-- TODO: fail if instances are running (with option to warn only)
-- TODO: identify master node, and put it last
......@@ -116,11 +124,13 @@ main opts args = do
colorings = map (\(v,a) -> (v,(colorVertMap.a) nodeGraph)) colorAlgorithms
smallestColoring =
(snd . minimumBy (comparing (IntMap.size . snd))) colorings
idToName = Node.name . (`Container.find` nlf)
nodesbycoloring = map (map idToName) $ IntMap.elems smallestColoring
idToNode = (`Container.find` nlf)
nodesRebootGroups = map (map idToNode) $ IntMap.elems smallestColoring
outputRebootGroups = filterOutput nodesRebootGroups
outputRebootNames = map (map Node.name) outputRebootGroups
when (verbose > 1) . putStrLn $ getStats colorings
unless (optNoHeaders opts) $
putStrLn "'Node Reboot Groups'"
mapM_ (putStrLn . commaJoin) nodesbycoloring
mapM_ (putStrLn . commaJoin) outputRebootNames
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