X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/53f00b200bee1102bfa3566670629bd729ccc15d..8930eef2ae36c3632d3aebb7f52482a1b3cef2a2:/Ganeti/HTools/Cluster.hs diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index 73c814a..0d14d15 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -563,27 +563,27 @@ computeMoves i a b c d = else if c == b then {- Failover and ... -} if d == a then {- that's all -} - ("f", [printf "migrate %s" i]) + ("f", [printf "migrate -f %s" i]) else (printf "f r:%s" d, - [printf "migrate %s" i, + [printf "migrate -f %s" i, printf "replace-disks -n %s %s" d i]) else if d == a then {- ... and keep primary as secondary -} (printf "r:%s f" c, [printf "replace-disks -n %s %s" c i, - printf "migrate %s" i]) + printf "migrate -f %s" i]) else if d == b then {- ... keep same secondary -} (printf "f r:%s f" c, - [printf "migrate %s" i, + [printf "migrate -f %s" i, printf "replace-disks -n %s %s" c i, - printf "migrate %s" i]) + printf "migrate -f %s" i]) else {- Nothing in common -} (printf "r:%s f r:%s" c d, [printf "replace-disks -n %s %s" c i, - printf "migrate %s" i, + printf "migrate -f %s" i, printf "replace-disks -n %s %s" d i]) {-| Converts a placement to string format -} @@ -616,9 +616,11 @@ printSolutionLine il ktn kti nmlen imlen plc pos = formatCmds :: [[String]] -> String formatCmds cmd_strs = - unlines $ map (" echo " ++) $ + unlines $ concat $ map (\(a, b) -> - (printf "step %d" (a::Int)):(map ("gnt-instance " ++) b)) $ + (printf "echo step %d" (a::Int)): + (printf "check"): + (map ("gnt-instance " ++) b)) $ zip [1..] cmd_strs {-| Converts a solution to string format -} @@ -788,6 +790,14 @@ nodeImem node il = in sum . map Instance.mem . map rfind $ Node.plist node +-- | Compute the amount of disk used by instances on a node (either primary +-- or secondary). +nodeIdsk :: Node.Node -> InstanceList -> Int +nodeIdsk node il = + let rfind = flip Container.find $ il + in sum . map Instance.dsk . + map rfind $ (Node.plist node) ++ (Node.slist node) + -- | Check cluster data for consistency checkData :: NodeList -> InstanceList -> NameList -> NameList @@ -804,12 +814,15 @@ checkData nl il ktn _ = - (Node.f_mem node) - (nodeImem node il) + adj_mem + delta_dsk = (truncate $ Node.t_dsk node) + - (Node.f_dsk node) + - (nodeIdsk node il) newn = Node.setFmem (Node.setXmem node delta_mem) (Node.f_mem node - adj_mem) - umsg = if delta_mem > 16 - then (printf "node %s has %6d MB of unaccounted \ - \memory " - nname delta_mem):msgs - else msgs - in (umsg, newn) + umsg1 = if delta_mem > 512 || delta_dsk > 1024 + then [printf "node %s is missing %d MB ram \ + \and %d GB disk" + nname delta_mem (delta_dsk `div` 1024)] + else [] + in (msgs ++ umsg1, newn) ) [] nl