checkInstanceMove function tries all possible moves of single instance in order to found an optimal move. When option --no-disk-moves is enabled, current implementation tries only Failover move while FailoverToAny is a suitable move too. This patch fixes the bug.
Signed-off-by: Oleg Ponomarev <[email protected]> --- src/Ganeti/HTools/Cluster.hs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Ganeti/HTools/Cluster.hs b/src/Ganeti/HTools/Cluster.hs index f76a05b..d6ffe2a 100644 --- a/src/Ganeti/HTools/Cluster.hs +++ b/src/Ganeti/HTools/Cluster.hs @@ -602,39 +602,44 @@ checkSingleStep ini_tbl target cur_tbl move = possibleMoves :: MirrorType -- ^ The mirroring type of the instance -> Bool -- ^ Whether the secondary node is a valid new node -> Bool -- ^ Whether we can change the primary node + -> Bool -- ^ Should moves contain disk moves or not -> (Bool, Bool) -- ^ Whether migration is restricted and whether -- the instance primary is offline -> Ndx -- ^ Target node candidate -> [IMove] -- ^ List of valid result moves -possibleMoves MirrorNone _ _ _ _ = [] +possibleMoves MirrorNone _ _ _ _ _ = [] -possibleMoves MirrorExternal _ False _ _ = [] +possibleMoves MirrorExternal _ False _ _ _ = [] -possibleMoves MirrorExternal _ True _ tdx = +possibleMoves MirrorExternal _ True False _ tdx = [ FailoverToAny tdx ] -possibleMoves MirrorInternal _ False _ tdx = +possibleMoves MirrorExternal _ True True _ _ = [] + +possibleMoves MirrorInternal _ _ False _ _ = [] + +possibleMoves MirrorInternal _ False True _ tdx = [ ReplaceSecondary tdx ] -possibleMoves MirrorInternal _ _ (True, False) tdx = +possibleMoves MirrorInternal _ _ True (True, False) tdx = [ ReplaceSecondary tdx ] -possibleMoves MirrorInternal True True (False, _) tdx = +possibleMoves MirrorInternal True True True (False, _) tdx = [ ReplaceSecondary tdx , ReplaceAndFailover tdx , ReplacePrimary tdx , FailoverAndReplace tdx ] -possibleMoves MirrorInternal True True (True, True) tdx = +possibleMoves MirrorInternal True True True (True, True) tdx = [ ReplaceSecondary tdx , ReplaceAndFailover tdx , FailoverAndReplace tdx ] -possibleMoves MirrorInternal False True _ tdx = +possibleMoves MirrorInternal False True True _ tdx = [ ReplaceSecondary tdx , ReplaceAndFailover tdx ] @@ -662,12 +667,14 @@ checkInstanceMove nodes_idx disk_moves inst_moves rest_mig primary_drained = Node.offline . flip Container.find nl $ Instance.pNode target + migrations = concatMap (possibleMoves mir_type use_secondary inst_moves + False (rest_mig, primary_drained)) nodes all_moves = if disk_moves - then concatMap (possibleMoves mir_type use_secondary inst_moves - (rest_mig, primary_drained)) - nodes - else [] + then migrations ++ + concatMap (possibleMoves mir_type use_secondary inst_moves + True (rest_mig, primary_drained)) nodes + else migrations in -- iterate over the possible nodes for this instance foldl' (checkSingleStep ini_tbl target) aft_failover all_moves -- 1.9.1
