From 8d38fb72c38b69a6a91fccce10ba5372eb04be77 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig <aehlig@google.com> Date: Tue, 7 May 2013 15:21:19 +0200 Subject: [PATCH] Support online-maintenance in hroller Make hroller take into account the nodes (redundant) instances will be migrated to. This be behavior can be overridden by the --offline-maintenance option which will make hroller plan under the assumption that all instances will be shutdown before starting with the rolling reboots. Signed-off-by: Klaus Aehlig <aehlig@google.com> Reviewed-by: Thomas Thrainer <thomasth@google.com> --- man/hroller.rst | 21 ++++++++++++++------- src/Ganeti/HTools/CLI.hs | 11 +++++++++++ src/Ganeti/HTools/Program/Hroller.hs | 6 +++++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/man/hroller.rst b/man/hroller.rst index 1caaf7be8..e39061d73 100644 --- a/man/hroller.rst +++ b/man/hroller.rst @@ -51,11 +51,13 @@ ALGORITHM FOR CALCULATING OFFLINE REBOOT GROUPS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hroller will view the nodes as vertices of an undirected graph, -connecting by instances which have both a primary and a secondary node. -It will then color the graph using a few different heuristics, and -return the minimum-size color set found. Node with the same color don't -share an edge, and as such don't have an instance with both primary and -secondary node on them, so they are safe to be rebooted concurrently. +with two kind of edges. Firstly, there are edges from the primary +to the secondary node of every instance. Secondly, two nodes are connected +by an edge if they are the primary nodes of two instances that have the +same secondary node. It will then color the graph using a few different +heuristics, and return the minimum-size color set found. Node with the same +color can then simultaneously migrate all instance off to their respective +secondary nodes, and it is safe to reboot them simultaneously. OPTIONS ------- @@ -69,6 +71,11 @@ For a description of the standard options check **htools**\(7) and \--one-step-only Restrict to the first reboot group. Output the group one node per line. +\--offline-maintenance + Pretend that all instances are shutdown before the reboots are carried + out. I.e., only edges from the primary to the secondary node of an instance + are considered. + \--force Do not fail, even if the master node cannot be determined. @@ -90,8 +97,8 @@ should support them both with and without secondary node replacement. EXAMPLE ------- -Offline Rolling node reboot output -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Rolling node reboot output +~~~~~~~~~~~~~~~~~~~~~~~~~~ With the default options, the program shows one reboot group per line as a comma-separated list. diff --git a/src/Ganeti/HTools/CLI.hs b/src/Ganeti/HTools/CLI.hs index c0687233d..33e241d5e 100644 --- a/src/Ganeti/HTools/CLI.hs +++ b/src/Ganeti/HTools/CLI.hs @@ -70,6 +70,7 @@ module Ganeti.HTools.CLI , oNoSimulation , oNodeSim , oNodeTags + , oOfflineMaintenance , oOfflineNode , oOneStepOnly , oOutputDir @@ -139,6 +140,7 @@ data Options = Options , optNodeSim :: [String] -- ^ Cluster simulation mode , optNodeTags :: Maybe [String] -- ^ List of node tags to restrict to , optOffline :: [String] -- ^ Names of offline nodes + , optOfflineMaintenance :: Bool -- ^ Pretend all instances are offline , optOneStepOnly :: Bool -- ^ Only do the first step , optOutPath :: FilePath -- ^ Path to the output directory , optSaveCluster :: Maybe FilePath -- ^ Save cluster state to this file @@ -188,6 +190,7 @@ defaultOptions = Options , optNodeSim = [] , optNodeTags = Nothing , optOffline = [] + , optOfflineMaintenance = False , optOneStepOnly = False , optOutPath = "." , optSaveCluster = Nothing @@ -465,6 +468,14 @@ oNodeTags = "TAG,...") "Restrict to nodes with the given tags", OptComplString) +oOfflineMaintenance :: OptType +oOfflineMaintenance = + (Option "" ["offline-maintenance"] + (NoArg (\ opts -> Ok opts {optOfflineMaintenance = True})) + "Schedule offline maintenance, i.e., pretend that all instance are\ + \ offline.", + OptComplNone) + oOfflineNode :: OptType oOfflineNode = (Option "O" ["offline"] diff --git a/src/Ganeti/HTools/Program/Hroller.hs b/src/Ganeti/HTools/Program/Hroller.hs index 576ffb85f..d62263b1b 100644 --- a/src/Ganeti/HTools/Program/Hroller.hs +++ b/src/Ganeti/HTools/Program/Hroller.hs @@ -58,6 +58,7 @@ options = do , oDataFile , oIAllocSrc , oOfflineNode + , oOfflineMaintenance , oVerbose , oQuiet , oNoHeaders @@ -143,10 +144,13 @@ main opts args = do , hasTag $ optNodeTags opts , hasGroup wantedGroup ]) nlf + mkGraph = if optOfflineMaintenance opts + then Node.mkNodeGraph + else Node.mkRebootNodeGraph nlf -- TODO: fail if instances are running (with option to warn only) - nodeGraph <- case Node.mkNodeGraph nodes ilf of + nodeGraph <- case mkGraph nodes ilf of Nothing -> exitErr "Cannot create node graph" Just g -> return g -- GitLab