Make hspace honor the option --accept-existing-errors. If
this option is given, hspace will try to allocate on all
N+1 happy nodes even though this might lead to overfull
groups.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 src/Ganeti/HTools/Program/Hspace.hs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Ganeti/HTools/Program/Hspace.hs 
b/src/Ganeti/HTools/Program/Hspace.hs
index 1620b6d..a4ddcc7 100644
--- a/src/Ganeti/HTools/Program/Hspace.hs
+++ b/src/Ganeti/HTools/Program/Hspace.hs
@@ -70,6 +70,7 @@ options = do
     , oVerbose
     , oQuiet
     , oIndependentGrps
+    , oAcceptExisting
     , oOfflineNode
     , oMachineReadable
     , oMaxCpu
@@ -451,6 +452,7 @@ main opts args = do
   let verbose = optVerbose opts
       machine_r = optMachineReadable opts
       independent_grps = optIndependentGrps opts
+      accept_existing = optAcceptExisting opts
 
   orig_cdata@(ClusterData gl fixed_nl il _ ipol) <- loadExternalData opts
   nl <- setNodeStatus opts fixed_nl
@@ -482,10 +484,13 @@ main opts args = do
     (Node.haveExclStorage nl)
 
   let (bad_items, _)  = Cluster.computeBadItems nl il
-      gl' = foldl (flip $ IntMap.adjust Group.setUnallocable) gl
-              $ map Node.group bad_items
+      gl' = if accept_existing
+              then gl
+              else foldl (flip $ IntMap.adjust Group.setUnallocable) gl
+                     (map Node.group bad_items)
       grps_remaining = any Group.isAllocable $ IntMap.elems gl'
       stop_allocation = case Cluster.computeBadItems nl il of
+                          _ | accept_existing-> Nothing
                           _ | independent_grps && grps_remaining -> Nothing
                           ([], _) -> Nothing
                           _ -> Just ([(FailN1, 1)]::FailStats, nl, il, [], [])
-- 
2.0.0.526.g5318336

Reply via email to