diff --git a/src/Ganeti/HTools/Cluster.hs b/src/Ganeti/HTools/Cluster.hs index cbf0ac16e3144bea61e23d3603f7fdf7b0820e65..f76a05b1e73cf05357c63ecad04a89abd2ebb826 100644 --- a/src/Ganeti/HTools/Cluster.hs +++ b/src/Ganeti/HTools/Cluster.hs @@ -460,7 +460,8 @@ applyMove nl inst Failover = int_s = Node.removeSec old_s inst new_nl = do -- Maybe monad new_p <- Node.addPriEx (Node.offline old_p) int_s inst - new_s <- Node.addSec int_p inst old_sdx + new_s <- Node.addSecExEx (Node.offline old_p) (Node.offline old_p) + int_p inst old_sdx let new_inst = Instance.setBoth inst old_sdx old_pdx return (Container.addTwo old_pdx new_s old_sdx new_p nl, new_inst, old_sdx, old_pdx) diff --git a/src/Ganeti/HTools/Node.hs b/src/Ganeti/HTools/Node.hs index 346f6bd3c31865375e749b392940394e13debc9e..fecc5fc528df23981ad33d7f8bb82acb81ff2c9b 100644 --- a/src/Ganeti/HTools/Node.hs +++ b/src/Ganeti/HTools/Node.hs @@ -66,6 +66,7 @@ module Ganeti.HTools.Node , addPriEx , addSec , addSecEx + , addSecExEx -- * Stats , availDisk , availMem @@ -571,7 +572,15 @@ addSec = addSecEx False -- | Adds a secondary instance (extended version). addSecEx :: Bool -> Node -> Instance.Instance -> T.Ndx -> T.OpResult Node -addSecEx force t inst pdx = +addSecEx = addSecExEx False + +-- | Adds a secondary instance (doubly extended version). The first parameter +-- tells `addSecExEx` to ignore disks completly. There is only one legitimate +-- use case for this, and this is failing over a DRBD instance where the primary +-- node is offline (and hence will become the secondary afterwards). +addSecExEx :: Bool + -> Bool -> Node -> Instance.Instance -> T.Ndx -> T.OpResult Node +addSecExEx ignore_disks force t inst pdx = let iname = Instance.idx inst old_peers = peers t old_mem = fMem t @@ -593,7 +602,7 @@ addSecEx force t inst pdx = strict = not force in case () of _ | not (Instance.hasSecondary inst) -> Bad T.FailDisk - | new_dsk <= 0 -> Bad T.FailDisk + | not ignore_disks && new_dsk <= 0 -> Bad T.FailDisk | new_dsk < loDsk t && strict -> Bad T.FailDisk | exclStorage t && new_free_sp < 0 -> Bad T.FailSpindles | new_inst_sp > hiSpindles t && strict -> Bad T.FailDisk