From b1a9d630651bb4074999c26cceb8a896dbfcecb4 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 28 Jun 2012 15:15:46 -0700 Subject: [PATCH] Remove can_rebalance functionality from hcheck Since hbal can now run rebalances even in the presence of split instances, we can remove this check and always run the rebalance. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Agata Murawska <agatamurawska@google.com> --- htools/Ganeti/HTools/Program/Hcheck.hs | 30 +++++++------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/htools/Ganeti/HTools/Program/Hcheck.hs b/htools/Ganeti/HTools/Program/Hcheck.hs index 13d1696c1..bf82c719c 100644 --- a/htools/Ganeti/HTools/Program/Hcheck.hs +++ b/htools/Ganeti/HTools/Program/Hcheck.hs @@ -100,9 +100,7 @@ groupData = commonData ++ [("SCORE", "Group score")] -- | Data showed per cluster. clusterData :: [(String, String)] clusterData = commonData ++ - [ ("NEED_REBALANCE", "Cluster is not healthy") - , ("CAN_REBALANCE", "Possible to run rebalance") - ] + [ ("NEED_REBALANCE", "Cluster is not healthy") ] -- | Phase-specific prefix for machine readable version. phasePrefix :: Phase -> String @@ -209,9 +207,9 @@ printGroupStats verbose machineread phase grp stats score = do printStats verbose machineread GroupLvl phase values (Just extradata) -- | Print all the statistics on a cluster (global) level. -printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> Bool -> IO () -printClusterStats verbose machineread phase stats needhbal canhbal = do - let values = prepareClusterValues machineread stats [needhbal, canhbal] +printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> IO () +printClusterStats verbose machineread phase stats needhbal = do + let values = prepareClusterValues machineread stats [needhbal] printStats verbose machineread ClusterLvl phase values Nothing -- | Check if any of cluster metrics is non-zero. @@ -298,8 +296,7 @@ main opts args = do (ClusterData gl fixed_nl ilf _ _) <- loadExternalData opts nlf <- setNodeStatus opts fixed_nl - let splitinstances = Cluster.findSplitInstances nlf ilf - splitcluster = Cluster.splitCluster nlf ilf + let splitcluster = Cluster.splitCluster nlf ilf when machineread $ printGroupsMappings gl @@ -307,40 +304,29 @@ main opts args = do splitcluster let clusterstats = map sum (transpose groupsstats) :: [Int] needrebalance = clusterNeedsRebalance clusterstats - canrebalance = length splitinstances == 0 printClusterStats verbose machineread Initial clusterstats needrebalance - canrebalance when nosimulation $ do unless (verbose == 0 || machineread) $ putStrLn "Running in no-simulation mode. Exiting." - when (length splitinstances > 0) $ do - unless (verbose == 0 || machineread) $ - putStrLn "Split instances found, simulation of re-balancing\ - \ not possible" - unless needrebalance $ do unless (verbose == 0 || machineread) $ putStrLn "No need to rebalance cluster, no problems found. Exiting." let exitOK = nosimulation || not needrebalance - simulate = not nosimulation && length splitinstances == 0 - && needrebalance + simulate = not nosimulation && needrebalance rebalancedcluster <- maybeSimulateRebalance simulate opts splitcluster when (simulate || machineread) $ do newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced gl) rebalancedcluster - -- We do not introduce new split instances during rebalance - let newsplitinstances = splitinstances - newclusterstats = map sum (transpose newgroupstats) :: [Int] + let newclusterstats = map sum (transpose newgroupstats) :: [Int] newneedrebalance = clusterNeedsRebalance clusterstats - newcanrebalance = length newsplitinstances == 0 printClusterStats verbose machineread Rebalanced newclusterstats - newneedrebalance newcanrebalance + newneedrebalance printFinalHTC machineread -- GitLab