From 3d7cd10bfc799ca2a6db1899f3afb232c8064ed5 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 16 Apr 2009 11:02:48 +0200 Subject: [PATCH] hbal: Abort for invalid offline node names Since it's easy to pass a wrong node name as offline, we should abort instead of silently ignoring it. --- Ganeti/HTools/Utils.hs | 1 + hbal.hs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Ganeti/HTools/Utils.hs b/Ganeti/HTools/Utils.hs index 81d5173e6..d1aa97557 100644 --- a/Ganeti/HTools/Utils.hs +++ b/Ganeti/HTools/Utils.hs @@ -10,6 +10,7 @@ module Ganeti.HTools.Utils , swapPairs , varianceCoeff , readData + , commaJoin ) where import Data.Either diff --git a/hbal.hs b/hbal.hs index e97b5127f..65c5e3f96 100644 --- a/hbal.hs +++ b/hbal.hs @@ -160,9 +160,16 @@ main = do putStrLn . unlines . map (\s -> printf " - %s" s) $ fix_msgs let offline_names = optOffline opts + all_names = snd . unzip $ ktn + offline_wrong = filter (\n -> not $ elem n all_names) offline_names offline_indices = fst . unzip . filter (\(_, n) -> elem n offline_names) $ ktn + when (length offline_wrong > 0) $ do + printf "Wrong node name(s) set as offline: %s\n" + (commaJoin offline_wrong) + exitWith $ ExitFailure 1 + let nl = Container.map (\n -> if elem (Node.idx n) offline_indices then Node.setOffline n True else n) fixed_nl -- GitLab