From 317b10407c6ea3e602b5ba7a7a5198eba92a73f4 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Mon, 17 May 2010 16:40:42 +0200 Subject: [PATCH] hspace: change handling of N+1 bad clusters Currently we just print a fake result and exit early. This is bad, since it doesn't use the same codepaths for all the result printing, and has already led to a bug where hspace looks like completely ignoring the tiered specs request. This patch changes the code to override the computation, instead of the printout, thus allowing tiered specs results for such cases. --- hspace.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hspace.hs b/hspace.hs index 058d30f..2b106ef 100644 --- a/hspace.hs +++ b/hspace.hs @@ -296,11 +296,8 @@ main = do printKeys $ printStats PInitial ini_stats let bad_nodes = fst $ Cluster.computeBadItems nl il - when (length bad_nodes > 0) $ do - -- This is failn1 case, so we print the same final stats and - -- exit early - printResults nl num_instances 0 [(FailN1, 1)] - exitWith ExitSuccess + stop_allocation = length bad_nodes > 0 + result_noalloc = ([(FailN1, 1)]::FailStats, nl, []) -- utility functions let iofspec spx = Instance.create "new" (rspecMem spx) (rspecDsk spx) @@ -319,8 +316,10 @@ main = do (case optTieredSpec opts of Nothing -> return () Just tspec -> do - let tresu = tieredAlloc nl il (iofspec tspec) req_nodes [] - (_, trl_nl, trl_ixes) <- exitifbad tresu + (_, trl_nl, trl_ixes) <- + if stop_allocation + then return result_noalloc + else exitifbad (tieredAlloc nl il (iofspec tspec) req_nodes []) let fin_trl_ixes = reverse trl_ixes ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs)) @@ -347,8 +346,10 @@ main = do -- Run the standard (avg-mode) allocation - let result = iterateDepth nl il reqinst req_nodes [] - (ereason, fin_nl, ixes) <- exitifbad result + (ereason, fin_nl, ixes) <- + if stop_allocation + then return result_noalloc + else exitifbad (iterateDepth nl il reqinst req_nodes []) let allocs = length ixes fin_ixes = reverse ixes -- 1.7.10.4