Revision b1a9d630 htools/Ganeti/HTools/Program/Hcheck.hs
b/htools/Ganeti/HTools/Program/Hcheck.hs | ||
---|---|---|
100 | 100 |
-- | Data showed per cluster. |
101 | 101 |
clusterData :: [(String, String)] |
102 | 102 |
clusterData = commonData ++ |
103 |
[ ("NEED_REBALANCE", "Cluster is not healthy") |
|
104 |
, ("CAN_REBALANCE", "Possible to run rebalance") |
|
105 |
] |
|
103 |
[ ("NEED_REBALANCE", "Cluster is not healthy") ] |
|
106 | 104 |
|
107 | 105 |
-- | Phase-specific prefix for machine readable version. |
108 | 106 |
phasePrefix :: Phase -> String |
... | ... | |
209 | 207 |
printStats verbose machineread GroupLvl phase values (Just extradata) |
210 | 208 |
|
211 | 209 |
-- | Print all the statistics on a cluster (global) level. |
212 |
printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> Bool -> IO ()
|
|
213 |
printClusterStats verbose machineread phase stats needhbal canhbal = do
|
|
214 |
let values = prepareClusterValues machineread stats [needhbal, canhbal]
|
|
210 |
printClusterStats :: Int -> Bool -> Phase -> [Int] -> Bool -> IO () |
|
211 |
printClusterStats verbose machineread phase stats needhbal = do |
|
212 |
let values = prepareClusterValues machineread stats [needhbal] |
|
215 | 213 |
printStats verbose machineread ClusterLvl phase values Nothing |
216 | 214 |
|
217 | 215 |
-- | Check if any of cluster metrics is non-zero. |
... | ... | |
298 | 296 |
(ClusterData gl fixed_nl ilf _ _) <- loadExternalData opts |
299 | 297 |
nlf <- setNodeStatus opts fixed_nl |
300 | 298 |
|
301 |
let splitinstances = Cluster.findSplitInstances nlf ilf |
|
302 |
splitcluster = Cluster.splitCluster nlf ilf |
|
299 |
let splitcluster = Cluster.splitCluster nlf ilf |
|
303 | 300 |
|
304 | 301 |
when machineread $ printGroupsMappings gl |
305 | 302 |
|
... | ... | |
307 | 304 |
splitcluster |
308 | 305 |
let clusterstats = map sum (transpose groupsstats) :: [Int] |
309 | 306 |
needrebalance = clusterNeedsRebalance clusterstats |
310 |
canrebalance = length splitinstances == 0 |
|
311 | 307 |
printClusterStats verbose machineread Initial clusterstats needrebalance |
312 |
canrebalance |
|
313 | 308 |
|
314 | 309 |
when nosimulation $ do |
315 | 310 |
unless (verbose == 0 || machineread) $ |
316 | 311 |
putStrLn "Running in no-simulation mode. Exiting." |
317 | 312 |
|
318 |
when (length splitinstances > 0) $ do |
|
319 |
unless (verbose == 0 || machineread) $ |
|
320 |
putStrLn "Split instances found, simulation of re-balancing\ |
|
321 |
\ not possible" |
|
322 |
|
|
323 | 313 |
unless needrebalance $ do |
324 | 314 |
unless (verbose == 0 || machineread) $ |
325 | 315 |
putStrLn "No need to rebalance cluster, no problems found. Exiting." |
326 | 316 |
|
327 | 317 |
let exitOK = nosimulation || not needrebalance |
328 |
simulate = not nosimulation && length splitinstances == 0 |
|
329 |
&& needrebalance |
|
318 |
simulate = not nosimulation && needrebalance |
|
330 | 319 |
|
331 | 320 |
rebalancedcluster <- maybeSimulateRebalance simulate opts splitcluster |
332 | 321 |
|
333 | 322 |
when (simulate || machineread) $ do |
334 | 323 |
newgroupstats <- mapM (perGroupChecks verbose machineread Rebalanced gl) |
335 | 324 |
rebalancedcluster |
336 |
-- We do not introduce new split instances during rebalance |
|
337 |
let newsplitinstances = splitinstances |
|
338 |
newclusterstats = map sum (transpose newgroupstats) :: [Int] |
|
325 |
let newclusterstats = map sum (transpose newgroupstats) :: [Int] |
|
339 | 326 |
newneedrebalance = clusterNeedsRebalance clusterstats |
340 |
newcanrebalance = length newsplitinstances == 0 |
|
341 | 327 |
|
342 | 328 |
printClusterStats verbose machineread Rebalanced newclusterstats |
343 |
newneedrebalance newcanrebalance
|
|
329 |
newneedrebalance |
|
344 | 330 |
|
345 | 331 |
printFinalHTC machineread |
346 | 332 |
|
Also available in: Unified diff