From 74e89a1432ee618dc13d64f8f4b1a52fb11dab71 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 26 Aug 2010 13:55:47 +0200
Subject: [PATCH] Fix ReplaceSecondary moves for offline nodes

The addition of a new secondary on a node is doing two memory tests:
- in strict mode, reject if we get into N+1 failure
- reject if the new instance memory is greater than the free memory (not
  available memory) on the node

The last check is designed to ensure that, irrespective of the other
secondary instances on this node, we are able to failover/migrate the
newly-added instance.

However, we should allow this, if the instances comes from an offline
node, which doesn't offer anything (not even disk replication).
Therefore this patch makes this check conditional on the strict mode.
---
 Ganeti/HTools/Node.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Ganeti/HTools/Node.hs b/Ganeti/HTools/Node.hs
index ece5e7b7c..37deec55e 100644
--- a/Ganeti/HTools/Node.hs
+++ b/Ganeti/HTools/Node.hs
@@ -409,7 +409,7 @@ addSecEx force t inst pdx =
     in case () of
          _ | new_dsk <= 0 -> T.OpFail T.FailDisk
            | mDsk t > new_dp && strict -> T.OpFail T.FailDisk
-           | Instance.mem inst >= old_mem -> T.OpFail T.FailMem
+           | Instance.mem inst >= old_mem && strict -> T.OpFail T.FailMem
            | new_failn1 && not (failN1 t) && strict -> T.OpFail T.FailMem
            | otherwise ->
                let new_slist = iname:sList t
-- 
GitLab