Skip to content
Snippets Groups Projects
Commit 5b658b83 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Make Hroller present master node last


If in the list of nodes to be scheduled for maintaince,
one is marked as being the master node, schedule it
as the last node in the last group.

Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 6c332a37
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,14 @@ filterOutput g l =
nonNullOnly = filter (not . null)
in nonNullOnly (map (onlineOnly . byGroupOnly g) l)
-- | Put the master node last.
-- Reorder a list of lists of nodes such that the master node (if present)
-- is the last node of the last group.
masterLast :: [[Node.Node]] -> [[Node.Node]]
masterLast rebootgroups =
map (uncurry (++)) . uncurry (++) . partition (null . snd) $
map (partition (not . Node.isMaster)) rebootgroups
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
......@@ -121,7 +129,6 @@ main opts args = do
Just grp -> return (Just grp)
-- TODO: fail if instances are running (with option to warn only)
-- TODO: identify master node, and put it last
nodeGraph <- case Node.mkNodeGraph nlf ilf of
Nothing -> exitErr "Cannot create node graph"
......@@ -138,7 +145,8 @@ main opts args = do
(snd . minimumBy (comparing (IntMap.size . snd))) colorings
idToNode = (`Container.find` nlf)
nodesRebootGroups = map (map idToNode) $ IntMap.elems smallestColoring
outputRebootGroups = filterOutput wantedGroup nodesRebootGroups
outputRebootGroups = masterLast $
filterOutput wantedGroup nodesRebootGroups
outputRebootNames = map (map Node.name) outputRebootGroups
when (verbose > 1) . putStrLn $ getStats colorings
......
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