From 22e513e7af50bc79305cb3271816a652e4f1faa4 Mon Sep 17 00:00:00 2001 From: Agata Murawska <agatamurawska@google.com> Date: Thu, 14 Jun 2012 17:38:33 +0200 Subject: [PATCH] Initial commit for introducting hcheck tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce infrastructure required to add Hcheck and build it successfuly. Signed-off-by: Agata Murawska <agatamurawska@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- Makefile.am | 4 +- htools/Ganeti/HTools/CLI.hs | 8 +++ htools/Ganeti/HTools/Program.hs | 2 + htools/Ganeti/HTools/Program/Hcheck.hs | 68 ++++++++++++++++++++++++ htools/cli-tests-defs.sh | 6 ++- man/hcheck.rst | 71 ++++++++++++++++++++++++++ man/htools.rst | 6 +++ 7 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 htools/Ganeti/HTools/Program/Hcheck.hs create mode 100644 man/hcheck.rst diff --git a/Makefile.am b/Makefile.am index 14d234562..138c6ca2c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -356,7 +356,7 @@ docrst = \ doc/walkthrough.rst HS_PROGS = htools/htools -HS_BIN_ROLES = hbal hscan hspace hinfo +HS_BIN_ROLES = hbal hscan hspace hinfo hcheck HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools htools/hconfd HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) @@ -399,6 +399,7 @@ HS_LIB_SRCS = \ htools/Ganeti/HTools/Program.hs \ htools/Ganeti/HTools/Program/Hail.hs \ htools/Ganeti/HTools/Program/Hbal.hs \ + htools/Ganeti/HTools/Program/Hcheck.hs \ htools/Ganeti/HTools/Program/Hinfo.hs \ htools/Ganeti/HTools/Program/Hscan.hs \ htools/Ganeti/HTools/Program/Hspace.hs \ @@ -692,6 +693,7 @@ man_MANS = \ man/gnt-os.8 \ man/hail.1 \ man/hbal.1 \ + man/hcheck.1 \ man/hinfo.1 \ man/hscan.1 \ man/hspace.1 \ diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs index 399ad87e8..aa4dc2c98 100644 --- a/htools/Ganeti/HTools/CLI.hs +++ b/htools/Ganeti/HTools/CLI.hs @@ -62,6 +62,7 @@ module Ganeti.HTools.CLI , oMinGainLim , oMinScore , oNoHeaders + , oNoSimulation , oNodeSim , oOfflineNode , oOutputDir @@ -133,6 +134,7 @@ data Options = Options , optMinGainLim :: Score -- ^ Limit below which we apply mingain , optMinScore :: Score -- ^ The minimum score we aim for , optNoHeaders :: Bool -- ^ Do not show a header line + , optNoSimulation :: Bool -- ^ Skip the rebalancing dry-run , optNodeSim :: [String] -- ^ Cluster simulation mode , optOffline :: [String] -- ^ Names of offline nodes , optOutPath :: FilePath -- ^ Path to the output directory @@ -175,6 +177,7 @@ defaultOptions = Options , optMinGainLim = 1e-1 , optMinScore = 1e-9 , optNoHeaders = False + , optNoSimulation = False , optNodeSim = [] , optOffline = [] , optOutPath = "." @@ -349,6 +352,11 @@ oNoHeaders = Option "" ["no-headers"] (NoArg (\ opts -> Ok opts { optNoHeaders = True })) "do not show a header line" +oNoSimulation :: OptType +oNoSimulation = Option "" ["no-simulation"] + (NoArg (\opts -> Ok opts {optNoSimulation = True})) + "do not perform rebalancing simulation" + oNodeSim :: OptType oNodeSim = Option "" ["simulate"] (ReqArg (\ f o -> Ok o { optNodeSim = f:optNodeSim o }) "SPEC") diff --git a/htools/Ganeti/HTools/Program.hs b/htools/Ganeti/HTools/Program.hs index 2817e83a3..75870e634 100644 --- a/htools/Ganeti/HTools/Program.hs +++ b/htools/Ganeti/HTools/Program.hs @@ -31,6 +31,7 @@ import Ganeti.HTools.CLI (OptType, Options) import qualified Ganeti.HTools.Program.Hail as Hail import qualified Ganeti.HTools.Program.Hbal as Hbal +import qualified Ganeti.HTools.Program.Hcheck as Hcheck import qualified Ganeti.HTools.Program.Hscan as Hscan import qualified Ganeti.HTools.Program.Hspace as Hspace import qualified Ganeti.HTools.Program.Hinfo as Hinfo @@ -39,6 +40,7 @@ import qualified Ganeti.HTools.Program.Hinfo as Hinfo personalities :: [(String, (Options -> [String] -> IO (), [OptType]))] personalities = [ ("hail", (Hail.main, Hail.options)) , ("hbal", (Hbal.main, Hbal.options)) + , ("hcheck", (Hcheck.main, Hcheck.options)) , ("hscan", (Hscan.main, Hscan.options)) , ("hspace", (Hspace.main, Hspace.options)) , ("hinfo", (Hinfo.main, Hinfo.options)) diff --git a/htools/Ganeti/HTools/Program/Hcheck.hs b/htools/Ganeti/HTools/Program/Hcheck.hs new file mode 100644 index 000000000..c73dcbdcc --- /dev/null +++ b/htools/Ganeti/HTools/Program/Hcheck.hs @@ -0,0 +1,68 @@ +{-| Cluster checker. + +-} + +{- + +Copyright (C) 2012 Google Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU Gene52al Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +-} + +module Ganeti.HTools.Program.Hcheck (main, options) where + +import Control.Monad +import System.Exit +import System.IO + +import Ganeti.HTools.CLI + +-- | Options list and functions. +options :: [OptType] +options = + [ oDataFile + , oDiskMoves + , oDynuFile + , oEvacMode + , oExInst + , oExTags + , oIAllocSrc + , oInstMoves + , oLuxiSocket + , oMachineReadable + , oMaxCpu + , oMaxSolLength + , oMinDisk + , oMinGain + , oMinGainLim + , oMinScore + , oNoSimulation + , oOfflineNode + , oQuiet + , oRapiMaster + , oSelInst + , oShowHelp + , oShowVer + , oVerbose + ] + +-- | Main function. +main :: Options -> [String] -> IO () +main _ args = do + unless (null args) $ do + hPutStrLn stderr "Error: this program doesn't take any arguments." + exitWith $ ExitFailure 1 diff --git a/htools/cli-tests-defs.sh b/htools/cli-tests-defs.sh index e34839be5..59d78ce9b 100644 --- a/htools/cli-tests-defs.sh +++ b/htools/cli-tests-defs.sh @@ -43,4 +43,8 @@ hinfo() { HTOOLS=hinfo $HBINARY "$@" } -ALL_ROLES="hbal hscan hail hspace hinfo" +hcheck() { + HTOOLS=hinfo $HBINARY "$@" +} + +ALL_ROLES="hbal hscan hail hspace hinfo hcheck" diff --git a/man/hcheck.rst b/man/hcheck.rst new file mode 100644 index 000000000..a09f02724 --- /dev/null +++ b/man/hcheck.rst @@ -0,0 +1,71 @@ +HCHECK(1) Ganeti | Version @GANETI_VERSION@ +=========================================== + +NAME +---- + +hcheck \- Cluster checker + +SYNOPSIS +-------- + +**hcheck** {backend options...} [algorithm options...] [reporting options...] + +**hcheck** \--version + + +Backend options: + +{ **-m** *cluster* | **-L[** *path* **] | **-t** *data-file* | +**-I** *path* } + +Algorithm options: + +**[ \--no-simulation ]** +**[ \--max-cpu *cpu-ratio* ]** +**[ \--min-disk *disk-ratio* ]** +**[ -l *limit* ]** +**[ -e *score* ]** +**[ -g *delta* ]** **[ \--min-gain-limit *threshold* ]** +**[ -O *name...* ]** +**[ \--no-disk-moves ]** +**[ \--no-instance-moves ]** +**[ -U *util-file* ]** +**[ \--evac-mode ]** +**[ \--select-instances *inst...* ]** +**[ \--exclude-instances *inst...* ]** + +Reporting options: + +**[\--machine-readable**[=*CHOICE*] **]** +**[ -p[ *fields* ] ]** +**[ \--print-instances ]** +**[ -v... | -q ]** + + +DESCRIPTION +----------- + +hcheck is the cluster checker. It prints information about cluster's +health and checks whether a rebalance done using **hbal** would help. +This information can be presented in both human-readable and +machine-readable way. +Note that it does not take any action, only performs a rebalance +simulation if necessary. +For more information about the algorithm details check **hbal(1)**. + +OPTIONS +------- + +\--no-simulation + Only perform checks based on current cluster state, without trying + to simulate rebalancing. + +For a detailed description about the options listed above have a look at +**htools(7)**, **hspace(1)** and **hbal(1)**. + +.. vim: set textwidth=72 : +.. Local Variables: +.. mode: rst +.. fill-column: 72 +.. End: diff --git a/man/htools.rst b/man/htools.rst index a05039b10..95205d189 100644 --- a/man/htools.rst +++ b/man/htools.rst @@ -12,6 +12,9 @@ SYNOPSIS **hbal** cluster balancer +**hcheck** + cluster checker + **hspace** cluster capacity computation @@ -35,6 +38,9 @@ environment variable HTOOLS can be used to set the desired role. Installed as ``hbal``, it computes and optionally executes a suite of instance moves in order to balance the cluster. +Installed as ``hcheck``, it preforms cluster checks and optionally +simulates rebalancing with all the ``hbal`` options available. + Installed as ``hspace``, it computes how many additional instances can be fit on a cluster, while maintaining N+1 status. It can run on models of existing clusters or of simulated clusters. -- GitLab