From a7e1fd8918b9d37123c06683bb9679aa44c4b541 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 27 Jun 2012 17:51:51 -0700 Subject: [PATCH] hbal: relax restrictions on split instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The recent patch series on hcheck made me realise how much pain we have due to hbal not being able to work (at all) with split instances. This is sub-optimal; ideally, hbal would degrade its behaviour, but not completely refuse to work. This patch does this, by marking any split instances as not movable (since such instances most likely mean that some manual intervention is done on then), but otherwise proceeding with the rebalance of the selected node group. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- htools/Ganeti/HTools/Loader.hs | 11 ++++++++++- htools/Ganeti/HTools/Program/Hbal.hs | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs index 446cc1044..5a5da6542 100644 --- a/htools/Ganeti/HTools/Loader.hs +++ b/htools/Ganeti/HTools/Loader.hs @@ -55,6 +55,7 @@ import qualified Ganeti.HTools.Container as Container import qualified Ganeti.HTools.Instance as Instance import qualified Ganeti.HTools.Node as Node import qualified Ganeti.HTools.Group as Group +import qualified Ganeti.HTools.Cluster as Cluster import Ganeti.HTools.Types import Ganeti.HTools.Utils @@ -246,6 +247,13 @@ updateMovable selinsts exinsts inst = then Instance.setMovable inst False else inst +-- | Disables moves for instances with a split group. +disableSplitMoves :: Node.List -> Instance.Instance -> Instance.Instance +disableSplitMoves nl inst = + if not . isOk . Cluster.instanceGroup nl $ inst + then Instance.setMovable inst False + else inst + -- | Compute the longest common suffix of a list of strings that -- starts with a dot. longestDomain :: [String] -> String @@ -302,8 +310,9 @@ mergeData um extags selinsts exinsts cdata@(ClusterData gl nl il2 tags _) = nl3 = Container.map (setNodePolicy gl . computeAlias common_suffix . (`Node.buildPeers` il4)) nl2 + il5 = Container.map (disableSplitMoves nl3) il4 in if' (null lkp_unknown) - (Ok cdata { cdNodes = nl3, cdInstances = il4 }) + (Ok cdata { cdNodes = nl3, cdInstances = il5 }) (Bad $ "Unknown instance(s): " ++ show(map lrContent lkp_unknown)) -- | Checks the cluster data for consistency. diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs index 7f542a5c9..3a361628b 100644 --- a/htools/Ganeti/HTools/Program/Hbal.hs +++ b/htools/Ganeti/HTools/Program/Hbal.hs @@ -301,11 +301,10 @@ checkCluster verbose nl il = do -- hbal doesn't currently handle split clusters let split_insts = Cluster.findSplitInstances nl il - unless (null split_insts) $ do + unless (null split_insts || verbose <= 1) $ do hPutStrLn stderr "Found instances belonging to multiple node groups:" mapM_ (\i -> hPutStrLn stderr $ " " ++ Instance.name i) split_insts - hPutStrLn stderr "Aborting." - exitWith $ ExitFailure 1 + hPutStrLn stderr "These instances will not be moved." printf "Loaded %d nodes, %d instances\n" (Container.size nl) -- GitLab