Commit 39f979b8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Update the loader pipeline to set the movable flag

This updates the movable flag on instances if they have only one node
(we don't rely on OpMoveInstance) or if they are set so via the command
line options.

This doesn't yet enable the use of the new flag.
parent a182df55
......@@ -87,6 +87,7 @@ loadExternalData opts = do
exTags = case optExTags opts of
Nothing -> []
Just etl -> map (++ ":") etl
exInsts = optExInst opts
when (length allSet > 1) $
do
......@@ -117,7 +118,7 @@ loadExternalData opts = do
| setFile -> wrapIO $ Text.loadData $ fromJust tfile
| otherwise -> return $ Bad "No backend selected! Exiting."
let ldresult = input_data >>= Loader.mergeData util_data' exTags
let ldresult = input_data >>= Loader.mergeData util_data' exTags exInsts
(loaded_nl, il, tags, csf) <-
(case ldresult of
Ok x -> return x
......
......@@ -111,7 +111,7 @@ parseData body = do
let (kti, il) = assignIndices iobj
-- cluster tags
ctags <- fromObj "cluster_tags" obj
(map_n, map_i, ptags, csf) <- mergeData [] [] (nl, il, ctags)
(map_n, map_i, ptags, csf) <- mergeData [] [] [] (nl, il, ctags)
optype <- fromObj "type" request
rqtype <-
case optype of
......
......@@ -129,6 +129,14 @@ filterExTags tl inst =
old_tags
in inst { Instance.tags = new_tags }
-- | Update the movable attribute
updateMovable :: [String] -> Instance.Instance -> Instance.Instance
updateMovable exinst inst =
if Instance.sNode inst == Node.noSecondary ||
Instance.name inst `elem` exinst
then Instance.setMovable inst False
else inst
-- | Compute the longest common suffix of a list of strings that
-- | starts with a dot.
longestDomain :: [String] -> String
......@@ -153,10 +161,11 @@ extractExTags =
-- list and massages it into the correct format.
mergeData :: [(String, DynUtil)] -- ^ Instance utilisation data
-> [String] -- ^ Exclusion tags
-> [String] -- ^ Untouchable instances
-> (Node.AssocList, Instance.AssocList, [String])
-- ^ Data from backends
-> Result (Node.List, Instance.List, [String], String)
mergeData um extags (nl, il, tags) =
mergeData um extags exinsts (nl, il, tags) =
let il2 = Container.fromAssocList il
il3 = foldl' (\im (name, n_util) ->
case Container.findByName im name of
......@@ -166,7 +175,8 @@ mergeData um extags (nl, il, tags) =
in Container.add (Instance.idx inst) new_i im
) il2 um
allextags = extags ++ extractExTags tags
il4 = Container.map (filterExTags allextags) il3
il4 = Container.map (filterExTags allextags .
updateMovable exinsts) il3
nl2 = foldl' fixNodes nl (Container.elems il4)
nl3 = Container.fromAssocList
(map (\ (k, v) -> (k, Node.buildPeers v il4)) nl2)
......
......@@ -137,7 +137,7 @@ main = do
printf "%-*s " nlen name
hFlush stdout
input_data <- Rapi.loadData name
let ldresult = input_data >>= Loader.mergeData [] []
let ldresult = input_data >>= Loader.mergeData [] [] []
(case ldresult of
Bad err -> printf "\nError: failed to load data. \
\Details:\n%s\n" err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment