cleanUpEvacuation :: IORef MemoryState
                  -> Instance.List
                  -> Container.Container AllReports
                  -> String
                  -> IO ()
cleanUpEvacuation memstate il reports name = do
  let insts = filter ((==) name . Instance.name) $ Container.elems il
  case insts of
    [] -> do
            logDebug $ "Instnace " ++ name ++ "no longer on the cluster"
            rmEvacuated memstate name
    inst:_ -> do
                 let nidx = Instance.pNode inst
                 when (isJust . findInstanceLoad name
                         $ Container.find nidx reports) $ do
                   logDebug $ "Load data for " ++ name ++ " available again"
                   rmEvacuated memstate name

-- * Balancing

-- | Transform an instance move into a submittable job.
cleanUpEvacuation :: IORef MemoryState
                  -> Instance.List
                  -> Container.Container AllReports
                  -> String
                  -> IO ()
cleanUpEvacuation memstate il reports name = do
  let insts = filter ((==) name . Instance.name) $ Container.elems il
  case insts of
    [] -> do
            logDebug $ "Instnace " ++ name ++ "no longer on the cluster"
            rmEvacuated memstate name
    inst:_ -> do
                 let nidx = Instance.pNode inst
                 when (isJust . findInstanceLoad name
                         $ Container.find nidx reports) $ do
                   logDebug $ "Load data for " ++ name ++ " available again"
                   rmEvacuated memstate name

-- * Balancing

-- | Transform an instance move into a submittable job.
cleanUpEvacuation memstate il reports name = do
  let insts = filter ((==) name . Instance.name) $ Container.elems il
  case insts of
    [] -> do
            logDebug $ "Instnace " ++ name ++ "no longer on the cluster"
            rmEvacuated memstate name
    inst:_ -> do
                 let nidx = Instance.pNode inst
                 when (isJust . findInstanceLoad name
                         $ Container.find nidx reports) $ do
                   logDebug $ "Load data for " ++ name ++ " available again"
                   rmEvacuated memstate name

-- * Balancing

-- | Transform an instance move into a submittable job.