Revision 5f4464db
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
508 | 508 |
-- | Given the status of the current secondary as a valid new node and |
509 | 509 |
-- the current candidate target node, generate the possible moves for |
510 | 510 |
-- a instance. |
511 |
possibleMoves :: Bool -- ^ Whether the secondary node is a valid new node |
|
512 |
-> Bool -- ^ Whether we can change the primary node |
|
513 |
-> Ndx -- ^ Target node candidate |
|
514 |
-> [IMove] -- ^ List of valid result moves |
|
511 |
possibleMoves :: MirrorType -- ^ The mirroring type of the instance |
|
512 |
-> Bool -- ^ Whether the secondary node is a valid new node |
|
513 |
-> Bool -- ^ Whether we can change the primary node |
|
514 |
-> Ndx -- ^ Target node candidate |
|
515 |
-> [IMove] -- ^ List of valid result moves |
|
515 | 516 |
|
516 |
possibleMoves _ False tdx = |
|
517 |
[ReplaceSecondary tdx] |
|
517 |
possibleMoves MirrorNone _ _ _ = [] |
|
518 | 518 |
|
519 |
possibleMoves True True tdx = |
|
519 |
possibleMoves MirrorExternal _ _ _ = [] |
|
520 |
|
|
521 |
possibleMoves MirrorInternal _ False tdx = |
|
522 |
[ ReplaceSecondary tdx ] |
|
523 |
|
|
524 |
possibleMoves MirrorInternal True True tdx = |
|
520 | 525 |
[ ReplaceSecondary tdx |
521 | 526 |
, ReplaceAndFailover tdx |
522 | 527 |
, ReplacePrimary tdx |
523 | 528 |
, FailoverAndReplace tdx |
524 | 529 |
] |
525 | 530 |
|
526 |
possibleMoves False True tdx = |
|
531 |
possibleMoves MirrorInternal False True tdx =
|
|
527 | 532 |
[ ReplaceSecondary tdx |
528 | 533 |
, ReplaceAndFailover tdx |
529 | 534 |
] |
... | ... | |
540 | 545 |
osdx = Instance.sNode target |
541 | 546 |
bad_nodes = [opdx, osdx] |
542 | 547 |
nodes = filter (`notElem` bad_nodes) nodes_idx |
548 |
mir_type = templateMirrorType $ Instance.diskTemplate target |
|
543 | 549 |
use_secondary = elem osdx nodes_idx && inst_moves |
544 |
aft_failover = if use_secondary -- if allowed to failover |
|
550 |
aft_failover = if mir_type == MirrorInternal && use_secondary |
|
551 |
-- if drbd and allowed to failover |
|
545 | 552 |
then checkSingleStep ini_tbl target ini_tbl Failover |
546 | 553 |
else ini_tbl |
547 |
all_moves = if disk_moves |
|
548 |
then concatMap |
|
549 |
(possibleMoves use_secondary inst_moves) nodes |
|
550 |
else [] |
|
554 |
all_moves = |
|
555 |
if disk_moves |
|
556 |
then concatMap (possibleMoves mir_type use_secondary inst_moves) |
|
557 |
nodes |
|
558 |
else [] |
|
551 | 559 |
in |
552 | 560 |
-- iterate over the possible nodes for this instance |
553 | 561 |
foldl' (checkSingleStep ini_tbl target) aft_failover all_moves |
Also available in: Unified diff