On Tue, Sep 01, 2015 at 08:36:18PM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
When deciding if a situation is redundant and AcceptExisting
is given, do not try to evacuate nodes that are offline already.
Signed-off-by: Klaus Aehlig <[email protected]>
---
src/Ganeti/HTools/Cluster.hs | 6 +++---
src/Ganeti/HTools/GlobalN1.hs | 15 ++++++++++-----
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/Ganeti/HTools/Cluster.hs b/src/Ganeti/HTools/Cluster.hs
index b8f1f60..8e4327c 100644
--- a/src/Ganeti/HTools/Cluster.hs
+++ b/src/Ganeti/HTools/Cluster.hs
@@ -510,7 +510,7 @@ tryAlloc _ _ _ _ (Right []) = fail "Not enough online
nodes"
tryAlloc opts nl il inst (Right ok_pairs) =
let cstat = compClusterStatistics $ Container.elems nl
n1pred = if algCapacity opts
- then allocGlobalN1 nl il
+ then allocGlobalN1 opts nl il
else const True
psols = parMap rwhnf (\(p, ss) ->
collectionToSolution FailN1 n1pred $
@@ -528,7 +528,7 @@ tryAlloc opts nl il inst (Left all_nodes) =
. allocateOnSingle opts nl inst
) emptyAllocCollection all_nodes
n1pred = if algCapacity opts
- then allocGlobalN1 nl il
+ then allocGlobalN1 opts nl il
else const True
in return . annotateSolution
$ collectionToSolution FailN1 n1pred sols
@@ -813,7 +813,7 @@ iterateAlloc' tryHugestep opts nl il limit newinst
allocnodes ixes cstats =
in case iterateAllocSmallStep opts' nl il limit'
newinst allocnodes ixes cstats of
Bad s -> Bad s
- Ok res@(_, nl', il', ixes', cstats') | redundant nl' il' ->
+ Ok res@(_, nl', il', ixes', cstats') | redundant opts nl' il' ->
if newlimit == Just 0 || length ixes' == length ixes
then return res
else iterateAlloc' tryHugestep opts nl' il' newlimit newinst
diff --git a/src/Ganeti/HTools/GlobalN1.hs b/src/Ganeti/HTools/GlobalN1.hs
index a4e6028..1ce0344 100644
--- a/src/Ganeti/HTools/GlobalN1.hs
+++ b/src/Ganeti/HTools/GlobalN1.hs
@@ -113,15 +113,20 @@ canEvacuateNode (nl, il) n = isOk $ do
foldM_ (recreate escapenodes) (nl'', il'') recreateInstances
-- | Predicate on wheter a given situation is globally N+1 redundant.
-redundant :: Node.List -> Instance.List -> Bool
-redundant nl il = Foldable.all (canEvacuateNode (nl, il)) nl
+redundant :: AlgorithmOptions -> Node.List -> Instance.List -> Bool
+redundant opts nl il =
+ let filterFun = if algAcceptExisting opts
+ then Container.filter (not . Node.offline)
+ else id
+ in Foldable.all (canEvacuateNode (nl, il)) $ filterFun nl
-- | Predicate on wheter an allocation element leads to a globally N+1 redundant
-- state.
-allocGlobalN1 :: Node.List -- ^ the original list of nodes
+allocGlobalN1 :: AlgorithmOptions
+ -> Node.List -- ^ the original list of nodes
-> Instance.List -- ^ the original list of instances
-> AllocSol.GenericAllocElement a -> Bool
-allocGlobalN1 nl il alloc =
+allocGlobalN1 opts nl il alloc =
let il' = AllocSol.updateIl il $ Just alloc
nl' = AllocSol.extractNl nl il $ Just alloc
- in redundant nl' il'
+ in redundant opts nl' il'
--
2.5.0.457.gab17608
LGTM