Commit 00b15752 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for 'offline' nodes

This patch drops compatiblity with Ganeti 1.2 and adds support for
offline nodes in the cluster. When reading from RAPI, the drained nodes
are considered offline so that we don't allocate on them too.
parent 3f6af65c
......@@ -753,10 +753,14 @@ loadData ndata idata =
let
{- node file: name t_mem n_mem f_mem t_disk f_disk -}
(ktn, nl) = loadTabular ndata
(\ (name:tm:nm:fm:td:fd:[]) ->
(\ (name:tm:nm:fm:td:fd:fo:[]) ->
(name,
Node.create (read tm) (read nm)
(read fm) (read td) (read fd)))
if any (== "?") [tm,nm,fm,td,fd] || fo == "Y" then
Node.create 0 0 0 0 0 True
else
Node.create (read tm) (read nm) (read fm)
(read td) (read fd) False
))
Node.setIdx
{- instance file: name mem disk status pnode snode -}
(kti, il) = loadTabular idata
......
......@@ -64,8 +64,9 @@ The index and the peers maps are empty, and will be need to be update
later via the 'setIdx' and 'buildPeers' functions.
-}
create :: Double -> Int -> Int -> Double -> Int -> Node
create mem_t_init mem_n_init mem_f_init dsk_t_init dsk_f_init =
create :: Double -> Int -> Int -> Double -> Int -> Bool -> Node
create mem_t_init mem_n_init mem_f_init dsk_t_init dsk_f_init
offline_init =
Node
{
t_mem = mem_t_init,
......@@ -82,7 +83,7 @@ create mem_t_init mem_n_init mem_f_init dsk_t_init dsk_f_init =
p_mem = (fromIntegral mem_f_init) / mem_t_init,
p_dsk = (fromIntegral dsk_f_init) / dsk_t_init,
p_rem = 0,
offline = False,
offline = offline_init,
x_mem = 0
}
......
......@@ -90,17 +90,28 @@ parseInstance a =
concatEitherElems running $
concatEitherElems pnode snode
boolToYN :: Bool -> Either String String
boolToYN True = Right "Y"
boolToYN _ = Right "N"
parseNode :: JSObject JSValue -> Either String String
parseNode a =
let name = getStringElement "name" a
offline = getBoolElement "offline" a
drained = getBoolElement "drained" a
mtotal = getIntElement "mtotal" a
mnode = getIntElement "mnode" a
mfree = getIntElement "mfree" a
dtotal = getIntElement "dtotal" a
dfree = getIntElement "dfree" a
in concatEitherElems name $
concatEitherElems (show `applyEither1` mtotal) $
concatEitherElems (show `applyEither1` mnode) $
concatEitherElems (show `applyEither1` mfree) $
concatEitherElems (show `applyEither1` dtotal)
(show `applyEither1` dfree)
(case offline of
Right True -> Right "0|0|0|0|0|Y"
_ ->
concatEitherElems (show `applyEither1` mtotal) $
concatEitherElems (show `applyEither1` mnode) $
concatEitherElems (show `applyEither1` mfree) $
concatEitherElems (show `applyEither1` dtotal) $
concatEitherElems (show `applyEither1` dfree)
((applyEither2 (||) offline drained) `combineEithers` boolToYN)
)
......@@ -20,6 +20,7 @@ module Ganeti.HTools.Utils
, fromObj
, getStringElement
, getIntElement
, getBoolElement
, getListElement
, getObjectElement
, asJSObject
......@@ -165,6 +166,9 @@ getStringElement = fromObj
getIntElement :: String -> JSObject JSValue -> Either String Int
getIntElement = fromObj
getBoolElement :: String -> JSObject JSValue -> Either String Bool
getBoolElement = fromObj
getListElement :: String -> JSObject JSValue
-> Either String [JSValue]
getListElement = fromObj
......
......@@ -2,7 +2,8 @@ Ganeti Cluster tools (htools)
=============================
These are some simple cluster tools for fixing common problems. Right
now N+1 and rebalancing are included.
now N+1 and rebalancing are included. Starting with version 0.1.0,
only Ganeti 2.0 is supported.
Cluster N+1 solver
......@@ -37,7 +38,7 @@ gathering if RAPI is available, which is better since it can extract
more precise information. In case RAPI is not usable for whatever
reason, the following two commands should be run::
gnt-node list -oname,mtotal,mnode,mfree,dtotal,dfree \
gnt-node list -oname,mtotal,mnode,mfree,dtotal,dfree,offline \
--separator '|' --no-headers > nodes
gnt-instance list -oname,admin_ram,sda_size,status,pnode,snodes \
--separator '|' --no-head > instances
......
......@@ -247,6 +247,9 @@ node is offline, since this move requires a failover.
these nodes will not be included in the score calculation (except for
the percentage of instances on offline nodes)
.RE
Note that hbal will also mark as offline any nodes which are reported
by RAPI as such, or that have "?" in file-based input in any numeric
fields.
.RE
.TP
......
......@@ -79,9 +79,11 @@ serializeNodes nl csf ktn =
t_mem = (truncate $ Node.t_mem node)::Int
t_dsk = (truncate $ Node.t_dsk node)::Int
in
printf "%s|%d|%d|%d|%d|%d" name
printf "%s|%d|%d|%d|%d|%d|%c" name
t_mem (Node.n_mem node) (Node.f_mem node)
t_dsk (Node.f_dsk node))
t_dsk (Node.f_dsk node)
(if Node.offline node then 'Y' else 'N')
)
nodes
in unlines nlines
......
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