Revision 929b60d8

b/htools/Ganeti/HTools/Node.hs
266 266
buildPeers t il =
267 267
    let mdata = map
268 268
                (\i_idx -> let inst = Container.find i_idx il
269
                           in (Instance.pNode inst, Instance.mem inst))
269
                               mem = if Instance.auto_balance inst
270
                                     then Instance.mem inst
271
                                     else 0
272
                           in (Instance.pNode inst, mem))
270 273
                (sList t)
271 274
        pmap = P.accumArray (+) mdata
272 275
        new_rmem = computeMaxRes pmap
......
329 332
        new_dsk = fDsk t + Instance.dsk inst
330 333
        old_peers = peers t
331 334
        old_peem = P.find pnode old_peers
332
        new_peem =  old_peem - Instance.mem inst
335
        new_peem =  if Instance.auto_balance inst
336
                    then old_peem - Instance.mem inst
337
                    else old_peem
333 338
        new_peers = if new_peem > 0
334 339
                    then P.add pnode new_peem old_peers
335 340
                    else P.remove pnode old_peers
......
402 407
        old_peers = peers t
403 408
        old_mem = fMem t
404 409
        new_dsk = fDsk t - Instance.dsk inst
405
        new_peem = P.find pdx old_peers + Instance.mem inst
410
        secondary_needed_mem = if Instance.auto_balance inst
411
                               then Instance.mem inst
412
                               else 0
413
        new_peem = P.find pdx old_peers + secondary_needed_mem
406 414
        new_peers = P.add pdx new_peem old_peers
407 415
        new_rmem = max (rMem t) new_peem
408 416
        new_prem = fromIntegral new_rmem / tMem t
......
415 423
    in case () of
416 424
         _ | new_dsk <= 0 -> T.OpFail T.FailDisk
417 425
           | mDsk t > new_dp && strict -> T.OpFail T.FailDisk
418
           | Instance.mem inst >= old_mem && strict -> T.OpFail T.FailMem
426
           | secondary_needed_mem >= old_mem && strict -> T.OpFail T.FailMem
419 427
           | new_failn1 && not (failN1 t) && strict -> T.OpFail T.FailMem
420 428
           | otherwise ->
421 429
               let new_slist = iname:sList t

Also available in: Unified diff