Skip to content
Snippets Groups Projects
Commit b1a9d630 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent f18e4168
No related branches found
No related tags found
No related merge requests found
...@@ -100,9 +100,7 @@ groupData = commonData ++ [("SCORE", "Group score")] ...@@ -100,9 +100,7 @@ groupData = commonData ++ [("SCORE", "Group score")]
-- | Data showed per cluster. -- | Data showed per cluster.
clusterData :: [(String, String)] clusterData :: [(String, String)]
clusterData = commonData ++ clusterData = commonData ++
[ ("NEED_REBALANCE", "Cluster is not healthy") [ ("NEED_REBALANCE", "Cluster is not healthy") ]
, ("CAN_REBALANCE", "Possible to run rebalance")
]
-- | Phase-specific prefix for machine readable version. -- | Phase-specific prefix for machine readable version.
phasePrefix :: Phase -> String phasePrefix :: Phase -> String
...@@ -209,9 +207,9 @@ printGroupStats verbose machineread phase grp stats score = do ...@@ -209,9 +207,9 @@ printGroupStats verbose machineread phase grp stats score = do
printStats verbose machineread GroupLvl phase values (Just extradata) printStats verbose machineread GroupLvl phase values (Just extradata)
-- | Print all the statistics on a cluster (global) level. -- | Print all the statistics on a cluster (global) level.
printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> Bool -> IO () printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> IO ()
printClusterStats verbose machineread phase stats needhbal canhbal = do printClusterStats verbose machineread phase stats needhbal = do
let values = prepareClusterValues machineread stats [needhbal, canhbal] let values = prepareClusterValues machineread stats [needhbal]
printStats verbose machineread ClusterLvl phase values Nothing printStats verbose machineread ClusterLvl phase values Nothing
-- | Check if any of cluster metrics is non-zero. -- | Check if any of cluster metrics is non-zero.
...@@ -298,8 +296,7 @@ main opts args = do ...@@ -298,8 +296,7 @@ main opts args = do
(ClusterData gl fixed_nl ilf _ _) <- loadExternalData opts (ClusterData gl fixed_nl ilf _ _) <- loadExternalData opts
nlf <- setNodeStatus opts fixed_nl nlf <- setNodeStatus opts fixed_nl
let splitinstances = Cluster.findSplitInstances nlf ilf let splitcluster = Cluster.splitCluster nlf ilf
splitcluster = Cluster.splitCluster nlf ilf
when machineread $ printGroupsMappings gl when machineread $ printGroupsMappings gl
...@@ -307,40 +304,29 @@ main opts args = do ...@@ -307,40 +304,29 @@ main opts args = do
splitcluster splitcluster
let clusterstats = map sum (transpose groupsstats) :: [Int] let clusterstats = map sum (transpose groupsstats) :: [Int]
needrebalance = clusterNeedsRebalance clusterstats needrebalance = clusterNeedsRebalance clusterstats
canrebalance = length splitinstances == 0
printClusterStats verbose machineread Initial clusterstats needrebalance printClusterStats verbose machineread Initial clusterstats needrebalance
canrebalance
when nosimulation $ do when nosimulation $ do
unless (verbose == 0 || machineread) $ unless (verbose == 0 || machineread) $
putStrLn "Running in no-simulation mode. Exiting." 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 needrebalance $ do
unless (verbose == 0 || machineread) $ unless (verbose == 0 || machineread) $
putStrLn "No need to rebalance cluster, no problems found. Exiting." putStrLn "No need to rebalance cluster, no problems found. Exiting."
let exitOK = nosimulation || not needrebalance let exitOK = nosimulation || not needrebalance
simulate = not nosimulation && length splitinstances == 0 simulate = not nosimulation && needrebalance
&& needrebalance
rebalancedcluster <- maybeSimulateRebalance simulate opts splitcluster rebalancedcluster <- maybeSimulateRebalance simulate opts splitcluster
when (simulate || machineread) $ do when (simulate || machineread) $ do
newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced gl) newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced gl)
rebalancedcluster rebalancedcluster
-- We do not introduce new split instances during rebalance let newclusterstats = map sum (transpose newgroupstats) :: [Int]
let newsplitinstances = splitinstances
newclusterstats = map sum (transpose newgroupstats) :: [Int]
newneedrebalance = clusterNeedsRebalance clusterstats newneedrebalance = clusterNeedsRebalance clusterstats
newcanrebalance = length newsplitinstances == 0
printClusterStats verbose machineread Rebalanced newclusterstats printClusterStats verbose machineread Rebalanced newclusterstats
newneedrebalance newcanrebalance newneedrebalance
printFinalHTC machineread printFinalHTC machineread
......
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