From a39779f62ec1c5aa64b338ea140a43ff9d197401 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig <aehlig@google.com> Date: Wed, 8 May 2013 13:46:40 +0200 Subject: [PATCH] Sort reboot groups by size Make hroller output the node groups not containing the master node sorted by size, largest group first. The master node still remains the last node of the last reboot group. In this way, most progress is made when switching back to normal cluster operations after the first reboot group. Signed-off-by: Klaus Aehlig <aehlig@google.com> Reviewed-by: Thomas Thrainer <thomasth@google.com> --- man/hroller.rst | 3 ++- src/Ganeti/HTools/Program/Hroller.hs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/man/hroller.rst b/man/hroller.rst index b96508b36..b55a68727 100644 --- a/man/hroller.rst +++ b/man/hroller.rst @@ -43,7 +43,8 @@ having both primary and secondary nodes being rebooted at the same time. For backends that support identifying the master node (currenlty RAPI and LUXI), the master node is scheduled as the last node -in the last reboot group. +in the last reboot group. Apart from this restriction, larger reboot +groups are put first. ALGORITHM FOR CALCULATING OFFLINE REBOOT GROUPS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Ganeti/HTools/Program/Hroller.hs b/src/Ganeti/HTools/Program/Hroller.hs index 8269c88e1..882bece8b 100644 --- a/src/Ganeti/HTools/Program/Hroller.hs +++ b/src/Ganeti/HTools/Program/Hroller.hs @@ -31,6 +31,7 @@ module Ganeti.HTools.Program.Hroller import Control.Applicative import Control.Monad +import Data.Function import Data.List import Data.Ord @@ -161,7 +162,9 @@ main opts args = do nodesRebootGroups = map (map idToNode . filter (`IntMap.member` nodes)) $ IntMap.elems smallestColoring - outputRebootGroups = masterLast nodesRebootGroups + outputRebootGroups = masterLast . + sortBy (flip compare `on` length) $ + nodesRebootGroups outputRebootNames = map (map Node.name) outputRebootGroups when (verbose > 1) . putStrLn $ getStats colorings -- GitLab