Add an option to hroller restoring the old behavior on not taking any non-redundant instances into account when forming reboot groups.
Signed-off-by: Klaus Aehlig <[email protected]> --- src/Ganeti/HTools/CLI.hs | 10 ++++++++++ src/Ganeti/HTools/Program/Hroller.hs | 17 ++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Ganeti/HTools/CLI.hs b/src/Ganeti/HTools/CLI.hs index 3a88c9d..fcfd221 100644 --- a/src/Ganeti/HTools/CLI.hs +++ b/src/Ganeti/HTools/CLI.hs @@ -55,6 +55,7 @@ module Ganeti.HTools.CLI , oForce , oGroup , oIAllocSrc + , oIgnoreNonRedundant , oInstMoves , oJobDelay , genOLuxiSocket @@ -125,6 +126,7 @@ data Options = Options , optForce :: Bool -- ^ Force the execution , optGroup :: Maybe GroupID -- ^ The UUID of the group to process , optIAllocSrc :: Maybe FilePath -- ^ The iallocation spec + , optIgnoreNonRedundant :: Bool -- ^ Ignore non-redundant instances , optSelInst :: [String] -- ^ Instances to be excluded , optLuxi :: Maybe FilePath -- ^ Collect data from Luxi , optJobDelay :: Double -- ^ Delay before executing first job @@ -176,6 +178,7 @@ defaultOptions = Options , optForce = False , optGroup = Nothing , optIAllocSrc = Nothing + , optIgnoreNonRedundant = False , optSelInst = [] , optLuxi = Nothing , optJobDelay = 10 @@ -356,6 +359,13 @@ oIAllocSrc = "Specify an iallocator spec as the cluster data source", OptComplFile) +oIgnoreNonRedundant :: OptType +oIgnoreNonRedundant = + (Option "" ["ignore-non-redundant"] + (NoArg (\ opts -> Ok opts { optIgnoreNonRedundant = True })) + "Pretend that there are no non-redundant instances in the cluster", + OptComplNone) + oJobDelay :: OptType oJobDelay = (Option "" ["job-delay"] diff --git a/src/Ganeti/HTools/Program/Hroller.hs b/src/Ganeti/HTools/Program/Hroller.hs index f567ba5..4be13d5 100644 --- a/src/Ganeti/HTools/Program/Hroller.hs +++ b/src/Ganeti/HTools/Program/Hroller.hs @@ -69,6 +69,7 @@ options = do , oSaveCluster , oGroup , oSkipNonRedundant + , oIgnoreNonRedundant , oForce , oOneStepOnly ] @@ -234,15 +235,17 @@ main opts args = do , ("Dcolor", colorDcolor) ] colorings = map (\(v,a) -> (v,(colorVertMap.a) nodeGraph)) colorAlgorithms - smallestColoring = + smallestColoring = IntMap.elems $ (snd . minimumBy (comparing (IntMap.size . snd))) colorings allNdx = map Node.idx $ Container.elems nlf - splitted = mapM (\ grp -> partitionNonRedundant grp allNdx (nlf,ilf)) $ - IntMap.elems smallestColoring - rebootGroups <- case splitted of - Ok splitgroups -> return $ concat splitgroups - Bad _ -> exitErr "Not enough capacity to move non-redundant\ - \ instances" + splitted = mapM (\ grp -> partitionNonRedundant grp allNdx (nlf,ilf)) + smallestColoring + rebootGroups <- if optIgnoreNonRedundant opts + then return smallestColoring + else case splitted of + Ok splitgroups -> return $ concat splitgroups + Bad _ -> exitErr "Not enough capacity to move\ + \ non-redundant instances" let idToNode = (`Container.find` nodes) nodesRebootGroups = map (map idToNode . filter (`IntMap.member` nodes)) rebootGroups -- 1.8.2.1
