Revision d52d41de

b/htools/Ganeti/HTools/Cluster.hs
939 939
        ops = iMoveToJob nl' il' idx (ReplaceSecondary ndx)
940 940
    return (nl', il', ops)
941 941

  
942
nodeEvacInstance _ _ _ (Instance.Instance
943
                        {Instance.diskTemplate = DTDrbd8}) _ =
944
                  fail "DRBD relocations not implemented yet"
942
nodeEvacInstance nl il ChangeAll
943
                 inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8})
944
                 avail_nodes =
945
  do
946
    let primary = Container.find (Instance.pNode inst) nl
947
        idx = Instance.idx inst
948
        gdx = instancePriGroup nl inst
949
        no_nodes = Left "no nodes available"
950
    -- if the primary is offline, then we first failover
951
    (nl1, inst1, ops1) <-
952
        if Node.offline primary
953
        then do
954
          (nl', inst', _, _) <-
955
              annotateResult "Failing over to the secondary" $
956
              opToResult $ applyMove nl inst Failover
957
          return (nl', inst', [Failover])
958
        else return (nl, inst, [])
959
    -- we now need to execute a replace secondary to the future
960
    -- primary node
961
    (nl2, inst2, _, new_pdx) <- annotateResult "Searching for a new primary" $
962
                                eitherToResult $
963
                                foldl' (evacDrbdSecondaryInner nl1 inst1 gdx)
964
                                no_nodes avail_nodes
965
    let ops2 = ReplaceSecondary new_pdx:ops1
966
    -- since we chose the new primary, we remove it from the list of
967
    -- available nodes
968
    let avail_nodes_sec = new_pdx `delete` avail_nodes
969
    -- we now execute another failover, the primary stays fixed now
970
    (nl3, inst3, _, _) <- annotateResult "Failing over to new primary" $
971
                          opToResult $ applyMove nl2 inst2 Failover
972
    let ops3 = Failover:ops2
973
    -- and finally another replace secondary, to the final secondary
974
    (nl4, inst4, _, new_sdx) <-
975
        annotateResult "Searching for a new secondary" $
976
        eitherToResult $
977
        foldl' (evacDrbdSecondaryInner nl3 inst3 gdx) no_nodes avail_nodes_sec
978
    let ops4 = ReplaceSecondary new_sdx:ops3
979
        il' = Container.add idx inst4 il
980
        ops = concatMap (iMoveToJob nl4 il' idx) $ reverse ops4
981
    return (nl4, il', ops)
945 982

  
946 983
-- | Inner fold function for changing secondary of a DRBD instance.
947 984
--

Also available in: Unified diff