diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs index f0ef0f290d34fe1280225dfc4eb6297653fe9668..14997625280ee8cc2ffd98f5375c5a7b4409d9bb 100644 --- a/htools/Ganeti/Confd/Server.hs +++ b/htools/Ganeti/Confd/Server.hs @@ -37,7 +37,6 @@ import Data.IORef import Data.List import qualified Data.Map as M import qualified Network.Socket as S -import Prelude hiding (catch) import System.Posix.Files import System.Posix.Types import System.Time @@ -307,7 +306,8 @@ updateConfig path r = do -- | Wrapper over 'updateConfig' that handles IO errors. safeUpdateConfig :: FilePath -> FStat -> CRef -> IO (FStat, ConfigReload) safeUpdateConfig path oldfstat cref = do - catch (do + Control.Exception.catch + (do nt <- needsReload oldfstat path case nt of Nothing -> return (oldfstat, ConfigToDate) @@ -430,7 +430,8 @@ onReloadInner inotiaction path cref -- it will return False. addNotifier :: INotify -> FilePath -> CRef -> MVar ServerState -> IO Bool addNotifier inotify path cref mstate = do - catch (addWatch inotify [CloseWrite] path + Control.Exception.catch + (addWatch inotify [CloseWrite] path (onInotify inotify path cref mstate) >> return True) (\e -> const (return False) (e::IOError)) diff --git a/htools/Ganeti/Daemon.hs b/htools/Ganeti/Daemon.hs index c6708f13fe25b070d2491c2e17f8951658d1d74b..f9848234be45218a054fdafe9b047d161b086487 100644 --- a/htools/Ganeti/Daemon.hs +++ b/htools/Ganeti/Daemon.hs @@ -48,7 +48,6 @@ import qualified Data.Version import Data.Word import GHC.IO.Handle (hDuplicateTo) import qualified Network.Socket as Socket -import Prelude hiding (catch) import System.Console.GetOpt import System.Exit import System.Environment @@ -218,7 +217,8 @@ formatIOError msg err = msg ++ ": " ++ show err -- 'Bad' value. writePidFile :: FilePath -> IO (Result Fd) writePidFile path = do - catch (fmap Ok $ _writePidFile path) + Control.Exception.catch + (fmap Ok $ _writePidFile path) (return . Bad . formatIOError "Failure during writing of the pid file") -- | Sets up a daemon's environment. @@ -282,8 +282,9 @@ parseAddress opts defport = do def_family <- Ssconf.getPrimaryIPFamily Nothing ainfo <- case optBindAddress opts of Nothing -> return (def_family >>= defaultBindAddr port) - Just saddr -> catch (resolveAddr port saddr) - (annotateIOError $ "Invalid address " ++ saddr) + Just saddr -> Control.Exception.catch + (resolveAddr port saddr) + (annotateIOError $ "Invalid address " ++ saddr) return ainfo -- | Run an I/O action as a daemon. diff --git a/htools/Ganeti/HTools/ExtLoader.hs b/htools/Ganeti/HTools/ExtLoader.hs index bd258f5f3cb63104bf01874db4a9c0ae538796f8..69248d63996435c9aab551916bff3bc357f6a037 100644 --- a/htools/Ganeti/HTools/ExtLoader.hs +++ b/htools/Ganeti/HTools/ExtLoader.hs @@ -36,7 +36,6 @@ module Ganeti.HTools.ExtLoader import Control.Monad import Control.Exception import Data.Maybe (isJust, fromJust) -import Prelude hiding (catch) import System.FilePath import System.IO import Text.Printf (hPrintf) @@ -55,7 +54,8 @@ import Ganeti.HTools.Utils (sepSplit, tryRead, exitIfBad, exitWhen) -- | Error beautifier. wrapIO :: IO (Result a) -> IO (Result a) -wrapIO = flip catch (\e -> return . Bad . show $ (e::IOException)) +wrapIO = flip Control.Exception.catch + (\e -> return . Bad . show $ (e::IOException)) -- | Parses a user-supplied utilisation string. parseUtilisation :: String -> Result (String, DynUtil) diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index c00e22d1523391b1b1907102f0f16b136958154b..133b0db8d769b0cef7e26b4b02fb30bfb3d76cd8 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -1363,7 +1363,8 @@ prop_ClusterAllocBalance = forAll (choose (3, 5)) $ \count -> not (Node.offline node) && not (Node.failN1 node) ==> let nl = makeSmallCluster node count - (hnode, nl') = IntMap.deleteFindMax nl + hnode = snd $ IntMap.findMax nl + nl' = IntMap.deleteMax nl il = Container.empty allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index 710bfbb6f6ca3a416051dccd19a5c733b65be9be..6f730174146b0603a7d3416529525dfbcbde709d 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -38,7 +38,6 @@ import Network.Curl import Network.Curl.Types () #endif import Control.Monad -import Prelude hiding (catch) import Text.JSON (JSObject, fromJSObject, decodeStrict) import Text.JSON.Types (JSValue(..)) import Text.Printf (printf) @@ -85,8 +84,8 @@ getUrl url = do -- | Helper to convert I/O errors in 'Bad' values. ioErrToResult :: IO a -> IO (Result a) ioErrToResult ioaction = - catch (ioaction >>= return . Ok) - (\e -> return . Bad . show $ (e::IOException)) + Control.Exception.catch (ioaction >>= return . Ok) + (\e -> return . Bad . show $ (e::IOException)) -- | Append the default port if not passed in. formatHost :: String -> String diff --git a/htools/Ganeti/Ssconf.hs b/htools/Ganeti/Ssconf.hs index 39a3d95dfaac6badae2dfdb5148ee17bb731fc3c..e0020cc098894c8e0f99a0f1bce0944d19178912 100644 --- a/htools/Ganeti/Ssconf.hs +++ b/htools/Ganeti/Ssconf.hs @@ -40,7 +40,6 @@ import Control.Exception import Control.Monad (liftM) import Data.Char (isSpace) import Data.Maybe (fromMaybe) -import Prelude hiding (catch) import qualified Network.Socket as Socket import System.FilePath ((</>)) import System.IO.Error (isDoesNotExistError) @@ -96,7 +95,8 @@ catchIOErrors :: Maybe a -- ^ Optional default -> IO a -- ^ Action to run -> IO (Result a) catchIOErrors def action = - catch (do + Control.Exception.catch + (do result <- action return (Ok result) ) (\err -> let bad_result = Bad (show err) diff --git a/htools/htools.hs b/htools/htools.hs index 2e847d7f2fc97655d349a78dfe950b8d237a200e..89081a70d9a7cde945f6f8892cf3d8d151a0ebd1 100644 --- a/htools/htools.hs +++ b/htools/htools.hs @@ -28,7 +28,6 @@ module Main (main) where import Control.Exception import Control.Monad (guard) import Data.Char (toLower) -import Prelude hiding (catch) import System.Environment import System.Exit import System.IO diff --git a/htools/test.hs b/htools/test.hs index 6e434274bc11ab5b9af918395897fbba307400b4..25519543bfd173e7a11173ca67cf83e8a0fe33c6 100644 --- a/htools/test.hs +++ b/htools/test.hs @@ -102,9 +102,8 @@ runTests name opts tests max_count = do printf "Test %s failed (seed was %s, test size %d): %s\n" desc (show u) size o GaveUp { numTests = passed } -> - printf "Test %s incomplete: gave up with only %d\ - \ passes after discarding %d tests\n" - desc passed (maxDiscard opts) + printf "Test %s incomplete: gave up with only %d passes\n" + desc passed _ -> return () ) results return results @@ -149,7 +148,6 @@ transformTestOpts args opts = do return args { chatty = optVerbose opts > 1 , replay = r , maxSuccess = fromMaybe (maxSuccess args) (optTestCount opts) - , maxDiscard = fromMaybe (maxDiscard args) (optTestCount opts) } main :: IO ()