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 <[email protected]>
---
 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 b96508b..b55a687 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 8269c88..882bece 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
-- 
1.8.2.1

Reply via email to