Skip to content
Snippets Groups Projects
Commit 92eacdd8 authored by Agata Murawska's avatar Agata Murawska
Browse files

Print info about ability to rebalance


As suggested during offline discussion, this patch adds a new bash
variable and description field in hcheck, which informs if the
rebalance was possible. This is to determine if there are split
instances on the cluster, in which case rebalance is impossible.

Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent e60fa4af
No related branches found
No related tags found
No related merge requests found
...@@ -113,12 +113,24 @@ groupData = commonData ++ [("SCORE", "Group score")] ...@@ -113,12 +113,24 @@ groupData = commonData ++ [("SCORE", "Group score")]
-- | Data showed per cluster. -- | Data showed per cluster.
clusterData :: [(String, String)] clusterData :: [(String, String)]
clusterData = commonData ++ [("NEED_REBALANCE", "Cluster is not healthy")] clusterData = commonData ++
[ ("NEED_REBALANCE", "Cluster is not healthy")
, ("CAN_REBALANCE", "Possible to run rebalance")
]
-- | Format a list of key, value as a shell fragment. -- | Format a list of key, value as a shell fragment.
printKeysHTC :: [(String, String)] -> IO () printKeysHTC :: [(String, String)] -> IO ()
printKeysHTC = printKeys htcPrefix printKeysHTC = printKeys htcPrefix
-- | Prepare string from boolean value.
printBool :: Bool -- ^ Whether the result should be machine readable
-> Bool -- ^ Value to be converted to string
-> String
printBool True True = "1"
printBool True False = "0"
printBool False b = show b
-- | Print all the statistics on a group level. -- | Print all the statistics on a group level.
printGroupStats :: Int -> Bool -> Phase -> Gdx -> [Int] -> Double -> IO () printGroupStats :: Int -> Bool -> Phase -> Gdx -> [Int] -> Double -> IO ()
printGroupStats _ True phase gidx stats score = do printGroupStats _ True phase gidx stats score = do
...@@ -140,26 +152,27 @@ printGroupStats verbose False phase gidx stats score = do ...@@ -140,26 +152,27 @@ printGroupStats verbose False phase gidx stats score = do
(zip groupData printstats) (zip groupData printstats)
-- | Print all the statistics on a cluster (global) level. -- | Print all the statistics on a cluster (global) level.
printClusterStats :: Int -> Bool -> Phase -> [Int] -> IO (Bool) printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> IO (Bool)
printClusterStats _ True phase stats = do printClusterStats _ True phase stats canrebal = do
let needrebal = sum stats let needrebal = sum stats > 0
printstats = map (printf "%d") $ stats ++ [needrebal] printstats = map (printf "%d") stats ++
:: [String] map (printBool True) [needrebal, canrebal]
printkeys = map (printf "%s_%s_%s" printkeys = map (printf "%s_%s_%s"
(phasePrefix phase) (phasePrefix phase)
(levelPrefix ClusterLvl)) (levelPrefix ClusterLvl))
(map fst clusterData) :: [String] (map fst clusterData) :: [String]
printKeysHTC (zip printkeys printstats) printKeysHTC (zip printkeys printstats)
return $ needrebal > 0 return needrebal
printClusterStats verbose False phase stats = do printClusterStats verbose False phase stats canrebal = do
let needrebal = sum stats let needrebal = sum stats > 0
printstats = map (printf "%d") stats :: [String] printstats = map (printf "%d") stats ++
map (printBool False) [needrebal, canrebal]
unless (verbose == 0) $ do unless (verbose == 0) $ do
printf "\nCluster statistics %s\n" (phaseDescription phase) :: IO () printf "\nCluster statistics %s\n" (phaseDescription phase) :: IO ()
mapM_ (\(a,b) -> printf " %s: %s\n" (snd a) b :: IO ()) mapM_ (\(a,b) -> printf " %s: %s\n" (snd a) b :: IO ())
(zip clusterData (printstats ++ [show (needrebal>0)])) (zip clusterData printstats)
return $ needrebal > 0 return needrebal
{- | Check group for N+1 hapiness, conflicts of primaries on nodes and {- | Check group for N+1 hapiness, conflicts of primaries on nodes and
instances residing on offline nodes. instances residing on offline nodes.
...@@ -233,7 +246,8 @@ main opts args = do ...@@ -233,7 +246,8 @@ main opts args = do
groupsstats <- mapM (perGroupChecks verbose machineread Initial) splitcluster groupsstats <- mapM (perGroupChecks verbose machineread Initial) splitcluster
let clusterstats = map sum (transpose groupsstats) :: [Int] let clusterstats = map sum (transpose groupsstats) :: [Int]
needrebalance <- printClusterStats verbose machineread Initial clusterstats canrebalance = length splitinstances == 0
needrebalance <- printClusterStats verbose machineread Initial clusterstats canrebalance
when nosimulation $ do when nosimulation $ do
unless (verbose == 0 || machineread) $ unless (verbose == 0 || machineread) $
...@@ -256,6 +270,6 @@ main opts args = do ...@@ -256,6 +270,6 @@ main opts args = do
newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced) newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced)
rebalancedcluster rebalancedcluster
let newclusterstats = map sum (transpose newgroupstats) :: [Int] let newclusterstats = map sum (transpose newgroupstats) :: [Int]
_ <- printClusterStats verbose machineread Rebalanced newclusterstats _ <- printClusterStats verbose machineread Rebalanced newclusterstats canrebalance
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