Commit 49148d15 authored by Iustin Pop's avatar Iustin Pop
Browse files

Move from hand-written man pages to RST/pandoc

This simplifies the maintenance of the man pages, and unifies the rst-to-*
converter to pandoc.
parent 92921ea4
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
/.hpc /.hpc
/coverage /coverage
/man/*.1
/doc/*.html
*.o *.o
*.patch *.patch
*.diff *.diff
......
HPROGS = hbal hscan hail hspace HPROGS = hbal hscan hail hspace
MANS = $(HPROGS:%=man/%.1)
HALLPROGS = $(HPROGS) test HALLPROGS = $(HPROGS) test
HSRCS := $(wildcard Ganeti/HTools/*.hs) $(wildcard Ganeti/*.hs) HSRCS := $(wildcard Ganeti/HTools/*.hs) $(wildcard Ganeti/*.hs)
HDDIR = apidoc HDDIR = apidoc
...@@ -13,7 +14,8 @@ HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC ...@@ -13,7 +14,8 @@ HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
# Haskell rules # Haskell rules
all: $(HPROGS) all: $(HPROGS) $(MANS)
$(HALLPROGS): %: %.hs Ganeti/HTools/Version.hs $(HSRCS) Makefile $(HALLPROGS): %: %.hs Ganeti/HTools/Version.hs $(HSRCS) Makefile
$(GHC) --make $(HFLAGS) $(HEXTRA) $@ $(GHC) --make $(HFLAGS) $(HEXTRA) $@
...@@ -23,7 +25,10 @@ test live-test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \ ...@@ -23,7 +25,10 @@ test live-test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
-fno-warn-missing-methods -fno-warn-unused-imports -fno-warn-missing-methods -fno-warn-unused-imports
$(DOCS) : %.html : % $(DOCS) : %.html : %
rst2html -v --strict $< $@ pandoc -f rst -t html -o $@ $<
%.1: %.rst
pandoc -s -f rst -t man -o $@ $<
doc: $(DOCS) Ganeti/HTools/Version.hs doc: $(DOCS) Ganeti/HTools/Version.hs
rm -rf $(HDDIR)/* rm -rf $(HDDIR)/*
...@@ -72,7 +77,7 @@ dist: regen-version Ganeti/HTools/Version.hs doc ...@@ -72,7 +77,7 @@ dist: regen-version Ganeti/HTools/Version.hs doc
rm -f $$ANAME $$ANAME.gz ; \ rm -f $$ANAME $$ANAME.gz ; \
git archive --format=tar --prefix=$$PFX/ HEAD > $$ANAME ; \ git archive --format=tar --prefix=$$PFX/ HEAD > $$ANAME ; \
tar -r -f $$ANAME --owner root --group root \ tar -r -f $$ANAME --owner root --group root \
--transform="s,^,$$PFX/," version apidoc $(DOCS) ; \ --transform="s,^,$$PFX/," version apidoc $(DOCS) $(MANS); \
gzip -v9 $$ANAME ; \ gzip -v9 $$ANAME ; \
TMPDIR=$$(mktemp -d) ; \ TMPDIR=$$(mktemp -d) ; \
tar xzf $$ANAME.gz -C $$TMPDIR; \ tar xzf $$ANAME.gz -C $$TMPDIR; \
......
...@@ -18,8 +18,8 @@ rebalance the cluster. ...@@ -18,8 +18,8 @@ rebalance the cluster.
**Quick start** (see the installation section for more details): **Quick start** (see the installation section for more details):
- (have the ghc compiler and the prerequisite libraries installed) - (have the ghc compiler and the prerequisite libraries installed)
- make - ``make``
- ./hbal -m $cluster -C -p - ``./hbal -m $cluster -C -p``
- look at the original and final cluster layout, and if acceptable, - look at the original and final cluster layout, and if acceptable,
execute the given commands execute the given commands
...@@ -35,7 +35,7 @@ cluster as equal as possible in their resource usage. It tries to ...@@ -35,7 +35,7 @@ cluster as equal as possible in their resource usage. It tries to
repeatedly move each instance one step, so that the cluster score repeatedly move each instance one step, so that the cluster score
becomes better. We stop when no further move can improve the score. becomes better. We stop when no further move can improve the score.
For algorithm details and usage, see the man page hbal(1). For algorithm details and usage, see the man page ``hbal(1)``.
IAllocator plugin IAllocator plugin
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
...@@ -46,7 +46,7 @@ needs to be installed in Ganeti's iallocator search path—usually ...@@ -46,7 +46,7 @@ needs to be installed in Ganeti's iallocator search path—usually
``/usr/lib/ganeti/iallocators`` or ``/usr/lib/ganeti/iallocators`` or
``/usr/local/lib/ganeti/iallocators``, and after that it can be used via ``/usr/local/lib/ganeti/iallocators``, and after that it can be used via
ganeti's ``--iallocator`` option (in various gnt-node/gnt-instance ganeti's ``--iallocator`` option (in various gnt-node/gnt-instance
commands). See the man page hail(1) for more details. commands). See the man page ``hail(1)`` for more details.
Cluster capacity estimator Cluster capacity estimator
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -88,12 +88,13 @@ If installing from source, you need a working ghc compiler (6.8 at ...@@ -88,12 +88,13 @@ If installing from source, you need a working ghc compiler (6.8 at
least) and some extra Haskell libraries which usually need to be least) and some extra Haskell libraries which usually need to be
installed manually: installed manually:
- json (http://hackage.haskell.org/package/json) - `json <http://hackage.haskell.org/package/json>`_
- curl (http://hackage.haskell.org/package/curl) - `curl <http://hackage.haskell.org/package/curl>`_
- network (http://hackage.haskell.org/package/network) - `network <http://hackage.haskell.org/package/network>`_
Once these are installed, just typing *make* in the top-level directory Once these are installed, just typing *make* in the top-level directory
should be enough. should be enough. If you edit the documentation sources, you will need
the ``pandoc`` program to rebuilt it.
Only the ``hail`` program needs to be installed in a specific place, the Only the ``hail`` program needs to be installed in a specific place, the
other tools are not location-dependent. other tools are not location-dependent.
......
.TH HBAL 1 2009-03-23 htools "Ganeti H-tools"
.SH NAME
hbal \- Cluster balancer for Ganeti
.SH SYNOPSIS
.B hbal
.B "[backend options...]"
.B "[algorithm options...]"
.B "[reporting options...]"
.B hbal
.B --version
.TP
Backend options:
.BI "[ -m " cluster " ]"
|
.BI "[ -L[" path "] [-X]]"
|
.BI "[ -t " data-file " ]"
.TP
Algorithm options:
.BI "[ --max-cpu " cpu-ratio " ]"
.BI "[ --min-disk " disk-ratio " ]"
.BI "[ -l " limit " ]"
.BI "[ -e " score " ]"
.BI "[ -g " delta " ] [ --min-gain-limit " threshold " ]"
.BI "[ -O " name... " ]"
.B "[ --no-disk-moves ]"
.BI "[ -U " util-file " ]"
.B "[ --evac-mode ]"
.BI "[ --exclude-instances " inst... " ]"
.TP
Reporting options:
.BI "[ -C[" file "] ]"
.BI "[ -p[" fields "] ]"
.B "[ --print-instances ]"
.B "[ -o ]"
.B "[ -v... | -q ]"
.SH DESCRIPTION
hbal is a cluster balancer that looks at the current state of the
cluster (nodes with their total and free disk, memory, etc.) and
instance placement and computes a series of steps designed to bring
the cluster into a better state.
The algorithm used is designed to be stable (i.e. it will give you the
same results when restarting it from the middle of the solution) and
reasonably fast. It is not, however, designed to be a perfect
algorithm \(em it is possible to make it go into a corner from which
it can find no improvement, because it looks only one "step" ahead.
By default, the program will show the solution incrementally as it is
computed, in a somewhat cryptic format; for getting the actual Ganeti
command list, use the \fB-C\fR option.
.SS ALGORITHM
The program works in independent steps; at each step, we compute the
best instance move that lowers the cluster score.
The possible move type for an instance are combinations of
failover/migrate and replace-disks such that we change one of the
instance nodes, and the other one remains (but possibly with changed
role, e.g. from primary it becomes secondary). The list is:
.RS 4
.TP 3
\(em
failover (f)
.TP
\(em
replace secondary (r)
.TP
\(em
replace primary, a composite move (f, r, f)
.TP
\(em
failover and replace secondary, also composite (f, r)
.TP
\(em
replace secondary and failover, also composite (r, f)
.RE
We don't do the only remaining possibility of replacing both nodes
(r,f,r,f or the equivalent f,r,f,r) since these move needs an
exhaustive search over both candidate primary and secondary nodes, and
is O(n*n) in the number of nodes. Furthermore, it doesn't seems to
give better scores but will result in more disk replacements.
.SS PLACEMENT RESTRICTIONS
At each step, we prevent an instance move if it would cause:
.RS 4
.TP 3
\(em
a node to go into N+1 failure state
.TP
\(em
an instance to move onto an offline node (offline nodes are either
read from the cluster or declared with \fI-O\fR)
.TP
\(em
an exclusion-tag based conflict (exclusion tags are read from the
cluster and/or defined via the \fI--exclusion-tags\fR option)
.TP
\(em
a max vcpu/pcpu ratio to be exceeded (configured via \fI--max-cpu\fR)
.TP
\(em
min disk free percentage to go below the configured limit (configured
via \fI--min-disk\fR)
.SS CLUSTER SCORING
As said before, the algorithm tries to minimise the cluster score at
each step. Currently this score is computed as a sum of the following
components:
.RS 4
.TP 3
\(em
standard deviation of the percent of free memory
.TP
\(em
standard deviation of the percent of reserved memory
.TP
\(em
standard deviation of the percent of free disk
.TP
\(em
count of nodes failing N+1 check
.TP
\(em
count of instances living (either as primary or secondary) on
offline nodes
.TP
\(em
count of instances living (as primary) on offline nodes; this differs
from the above metric by helping failover of such instances in 2-node
clusters
.TP
\(em
standard deviation of the ratio of virtual-to-physical cpus (for
primary instances of the node)
.TP
\(em
standard deviation of the dynamic load on the nodes, for cpus,
memory, disk and network
.RE
The free memory and free disk values help ensure that all nodes are
somewhat balanced in their resource usage. The reserved memory helps
to ensure that nodes are somewhat balanced in holding secondary
instances, and that no node keeps too much memory reserved for
N+1. And finally, the N+1 percentage helps guide the algorithm towards
eliminating N+1 failures, if possible.
Except for the N+1 failures and offline instances counts, we use the
standard deviation since when used with values within a fixed range
(we use percents expressed as values between zero and one) it gives
consistent results across all metrics (there are some small issues
related to different means, but it works generally well). The 'count'
type values will have higher score and thus will matter more for
balancing; thus these are better for hard constraints (like evacuating
nodes and fixing N+1 failures). For example, the offline instances
count (i.e. the number of instances living on offline nodes) will
cause the algorithm to actively move instances away from offline
nodes. This, coupled with the restriction on placement given by
offline nodes, will cause evacuation of such nodes.
The dynamic load values need to be read from an external file (Ganeti
doesn't supply them), and are computed for each node as: sum of
primary instance cpu load, sum of primary instance memory load, sum of
primary and secondary instance disk load (as DRBD generates write load
on secondary nodes too in normal case and in degraded scenarios also
read load), and sum of primary instance network load. An example of
how to generate these values for input to hbal would be to track "xm
list" for instance over a day and by computing the delta of the cpu
values, and feed that via the \fI-U\fR option for all instances (and
keep the other metrics as one). For the algorithm to work, all that is
needed is that the values are consistent for a metric across all
instances (e.g. all instances use cpu% to report cpu usage, and not
something related to number of CPU seconds used if the CPUs are
different), and that they are normalised to between zero and one. Note
that it's recommended to not have zero as the load value for any
instance metric since then secondary instances are not well balanced.
On a perfectly balanced cluster (all nodes the same size, all
instances the same size and spread across the nodes equally), the
values for all metrics would be zero. This doesn't happen too often in
practice :)
.SS OFFLINE INSTANCES
Since current Ganeti versions do not report the memory used by offline
(down) instances, ignoring the run status of instances will cause
wrong calculations. For this reason, the algorithm subtracts the
memory size of down instances from the free node memory of their
primary node, in effect simulating the startup of such instances.
.SS EXCLUSION TAGS
The exclusion tags mechanism is designed to prevent instances which
run the same workload (e.g. two DNS servers) to land on the same node,
which would make the respective node a SPOF for the given service.
It works by tagging instances with certain tags and then building
exclusion maps based on these. Which tags are actually used is
configured either via the command line (option \fI--exclusion-tags\fR)
or via adding them to the cluster tags:
.TP
.B --exclusion-tags=a,b
This will make all instance tags of the form \fIa:*\fR, \fIb:*\fR be
considered for the exclusion map
.TP
cluster tags \fBhtools:iextags:a\fR, \fBhtools:iextags:b\fR
This will make instance tags \fIa:*\fR, \fIb:*\fR be considered for
the exclusion map. More precisely, the suffix of cluster tags starting
with \fBhtools:iextags:\fR will become the prefix of the exclusion
tags.
.P
Both the above forms mean that two instances both having (e.g.) the
tag \fIa:foo\fR or \fIb:bar\fR won't end on the same node.
.SH OPTIONS
The options that can be passed to the program are as follows:
.TP
.B -C, --print-commands
Print the command list at the end of the run. Without this, the
program will only show a shorter, but cryptic output.
Note that the moves list will be split into independent steps, called
"jobsets", but only for visual inspection, not for actually
parallelisation. It is not possible to parallelise these directly when
executed via "gnt-instance" commands, since a compound command
(e.g. failover and replace\-disks) must be executed serially. Parallel
execution is only possible when using the Luxi backend and the
\fI-L\fR option.
The algorithm for splitting the moves into jobsets is by accumulating
moves until the next move is touching nodes already touched by the
current moves; this means we can't execute in parallel (due to
resource allocation in Ganeti) and thus we start a new jobset.
.TP
.B -p, --print-nodes
Prints the before and after node status, in a format designed to allow
the user to understand the node's most important parameters.
It is possible to customise the listed information by passing a
comma\(hyseparated list of field names to this option (the field list
is currently undocumented), or to extend the default field list by
prefixing the additional field list with a plus sign. By default, the
node list will contain the following information:
.RS
.TP
.B F
a character denoting the status of the node, with '\-' meaning an
offline node, '*' meaning N+1 failure and blank meaning a good node
.TP
.B Name
the node name
.TP
.B t_mem
the total node memory
.TP
.B n_mem
the memory used by the node itself
.TP
.B i_mem
the memory used by instances
.TP
.B x_mem
amount memory which seems to be in use but cannot be determined why or
by which instance; usually this means that the hypervisor has some
overhead or that there are other reporting errors
.TP
.B f_mem
the free node memory
.TP
.B r_mem
the reserved node memory, which is the amount of free memory needed
for N+1 compliance
.TP
.B t_dsk
total disk
.TP
.B f_dsk
free disk
.TP
.B pcpu
the number of physical cpus on the node
.TP
.B vcpu
the number of virtual cpus allocated to primary instances
.TP
.B pcnt
number of primary instances
.TP
.B scnt
number of secondary instances
.TP
.B p_fmem
percent of free memory
.TP
.B p_fdsk
percent of free disk
.TP
.B r_cpu
ratio of virtual to physical cpus
.TP
.B lCpu
the dynamic CPU load (if the information is available)
.TP
.B lMem
the dynamic memory load (if the information is available)
.TP
.B lDsk
the dynamic disk load (if the information is available)
.TP
.B lNet
the dynamic net load (if the information is available)
.RE
.TP
.B --print-instances
Prints the before and after instance map. This is less useful as the
node status, but it can help in understanding instance moves.
.TP
.B -o, --oneline
Only shows a one\(hyline output from the program, designed for the case
when one wants to look at multiple clusters at once and check their
status.
The line will contain four fields:
.RS
.RS 4
.TP 3
\(em
initial cluster score
.TP
\(em
number of steps in the solution
.TP
\(em
final cluster score
.TP
\(em
improvement in the cluster score
.RE
.RE
.TP
.BI "-O " name
This option (which can be given multiple times) will mark nodes as
being \fIoffline\fR. This means a couple of things:
.RS
.RS 4
.TP 3
\(em
instances won't be placed on these nodes, not even temporarily;
e.g. the \fIreplace primary\fR move is not available if the secondary
node is offline, since this move requires a failover.
.TP
\(em
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\(hybased input in any numeric
fields.
.RE
.TP
.BI "-e" score ", --min-score=" score
This parameter denotes the minimum score we are happy with and alters
the computation in two ways:
.RS
.RS 4
.TP 3
\(em
if the cluster has the initial score lower than this value, then we
don't enter the algorithm at all, and exit with success
.TP
\(em
during the iterative process, if we reach a score lower than this
value, we exit the algorithm
.RE
The default value of the parameter is currently \fI1e-9\fR (chosen
empirically).
.RE
.TP
.BI "-g" delta ", --min-gain=" delta
Since the balancing algorithm can sometimes result in just very tiny
improvements, that bring less gain that they cost in relocation time,
this parameter (defaulting to 0.01) represents the minimum gain we
require during a step, to continue balancing.
.TP
.BI "--min-gain-limit=" threshold
The above min-gain option will only take effect if the cluster score
is already below \fIthreshold\fR (defaults to 0.1). The rationale
behind this setting is that at high cluster scores (badly balanced
clusters), we don't want to abort the rebalance too quickly, as later
gains might still be significant. However, under the threshold, the
total gain is only the threshold value, so we can exit early.
.TP
.BI "--no-disk-moves"
This parameter prevents hbal from using disk move (i.e. "gnt\-instance
replace\-disks") operations. This will result in a much quicker
balancing, but of course the improvements are limited. It is up to the
user to decide when to use one or another.
.TP
.B "--evac-mode"
This parameter restricts the list of instances considered for moving
to the ones living on offline/drained nodes. It can be used as a
(bulk) replacement for Ganeti's own \fIgnt-node evacuate\fR, with the
note that it doesn't guarantee full evacuation.
.TP
.BI "--exclude-instances " instances
This parameter marks the given instances (as a comma-separated list)
from being moved during the rebalance.
.TP
.BI "-U" util-file
This parameter specifies a file holding instance dynamic utilisation
information that will be used to tweak the balancing algorithm to
equalise load on the nodes (as opposed to static resource usage). The
file is in the format "instance_name cpu_util mem_util disk_util
net_util" where the "_util" parameters are interpreted as numbers and
the instance name must match exactly the instance as read from
Ganeti. In case of unknown instance names, the program will abort.
If not given, the default values are one for all metrics and thus
dynamic utilisation has only one effect on the algorithm: the
equalisation of the secondary instances across nodes (this is the only
metric that is not tracked by another, dedicated value, and thus the
disk load of instances will cause secondary instance
equalisation). Note that value of one will also influence slightly the
primary instance count, but that is already tracked via other metrics
and thus the influence of the dynamic utilisation will be practically
insignificant.
.TP
.BI "-t" datafile ", --text-data=" datafile
The name of the file holding node and instance information (if not
collecting via RAPI or LUXI). This or one of the other backends must
be selected.
.TP
.BI "-S" datafile ", --save-cluster=" datafile
If given, the state of the cluster at the end of the balancing is
saved to the given file. This allows re-feeding the cluster state to
either hbal itself or for example hspace.
.TP
.BI "-m" cluster
Collect data directly from the
.I cluster
given as an argument via RAPI. If the argument doesn't contain a colon
(:), then it is converted into a fully\(hybuilt URL via prepending
https:// and appending the default RAPI port, otherwise it's
considered a fully\(hyspecified URL and is used as\(hyis.
.TP
.BI "-L[" path "]"
Collect data directly from the master daemon, which is to be contacted
via the luxi (an internal Ganeti protocol). An optional \fIpath\fR
argument is interpreted as the path to the unix socket on which the
master daemon listens; otherwise, the default path used by ganeti when
installed with \fI--localstatedir=/var\fR is used.
.TP
.B "-X"
When using the Luxi backend, hbal can also execute the given
commands. The execution method is to execute the individual jobsets
(see the \fI-C\fR option for details) in separate stages, aborting if
at any time a jobset doesn't have all jobs successful. Each step in
the balancing solution will be translated into exactly one Ganeti job
(having between one and three OpCodes), and all the steps in a jobset
will be executed in parallel. The jobsets themselves are executed
serially.
.TP
.BI "-l" N ", --max-length=" N
Restrict the solution to this length. This can be used for example to
automate the execution of the balancing.
.TP
.BI "--max-cpu " cpu-ratio
The maximum virtual\(hyto\(hyphysical cpu ratio, as a floating point
number between zero and one. For example, specifying \fIcpu-ratio\fR
as \fB2.5\fR means that, for a 4\(hycpu machine, a maximum of 10
virtual cpus should be allowed to be in use for primary instances. A
value of one doesn't make sense though, as that means no disk space
can be used on it.
.TP
.BI "--min-disk " disk-ratio
The minimum amount of free disk space remaining, as a floating point
number. For example, specifying \fIdisk-ratio\fR as \fB0.25\fR means
that at least one quarter of disk space should be left free on nodes.
.TP
.B -v, --verbose
Increase the output verbosity. Each usage of this option will increase
the verbosity (currently more than 2 doesn't make sense) from the
default of one.
.TP
.B -q, --quiet
Decrease the output verbosity. Each usage of this option will decrease
the verbosity (less than zero doesn't make sense) from the default of
one.
.TP
.B -V, --version
Just show the program version and exit.
.SH EXIT STATUS
The exist status of the command will be zero, unless for some reason
the algorithm fatally failed (e.g. wrong node or instance data).
.SH ENVIRONMENT
If the variables \fBHTOOLS_NODES\fR and \fBHTOOLS_INSTANCES\fR are
present in the environment, they will override the default names for
the nodes and instances files. These will have of course no effect
when the RAPI or Luxi backends are used.
.SH BUGS
The program does not check its input data for consistency, and aborts