Skip to content
Snippets Groups Projects
Commit f688711c authored by Iustin Pop's avatar Iustin Pop
Browse files

hscan: return exit code 2 for RAPI failures

If some clusters failed during RAPI collection, exit with exit code 2 so
that tests can detect this failure.
parent b7478ce1
No related branches found
No related tags found
No related merge requests found
...@@ -30,9 +30,7 @@ module Main (main) where ...@@ -30,9 +30,7 @@ module Main (main) where
import Data.List import Data.List
import Data.Maybe (isJust, fromJust, fromMaybe) import Data.Maybe (isJust, fromJust, fromMaybe)
import Monad import Monad
#ifdef NO_CURL
import System (exitWith, ExitCode(..)) import System (exitWith, ExitCode(..))
#endif
import System.IO import System.IO
import System.FilePath import System.FilePath
import qualified System import qualified System
...@@ -139,9 +137,10 @@ writeData :: Int ...@@ -139,9 +137,10 @@ writeData :: Int
-> String -> String
-> Options -> Options
-> Result (Node.List, Instance.List, String) -> Result (Node.List, Instance.List, String)
-> IO () -> IO Bool
writeData _ name _ (Bad err) = writeData _ name _ (Bad err) =
printf "\nError for %s: failed to load data. Details:\n%s\n" name err printf "\nError for %s: failed to load data. Details:\n%s\n" name err >>
return False
writeData nlen name opts (Ok (nl, il, adata)) = do writeData nlen name opts (Ok (nl, il, adata)) = do
printf "%-*s " nlen name :: IO () printf "%-*s " nlen name :: IO ()
...@@ -154,7 +153,7 @@ writeData nlen name opts (Ok (nl, il, adata)) = do ...@@ -154,7 +153,7 @@ writeData nlen name opts (Ok (nl, il, adata)) = do
when (isJust shownodes) $ when (isJust shownodes) $
putStr $ Cluster.printNodes nl (fromJust shownodes) putStr $ Cluster.printNodes nl (fromJust shownodes)
writeFile (oname <.> "data") adata writeFile (oname <.> "data") adata
return True
-- | Main function. -- | Main function.
main :: IO () main :: IO ()
...@@ -176,14 +175,16 @@ main = do ...@@ -176,14 +175,16 @@ main = do
let lsock = fromMaybe defaultLuxiSocket (optLuxi opts) let lsock = fromMaybe defaultLuxiSocket (optLuxi opts)
let name = local let name = local
input_data <- Luxi.loadData lsock input_data <- Luxi.loadData lsock
writeData nlen name opts (processData input_data) result <- writeData nlen name opts (processData input_data)
when (not result) $ exitWith $ ExitFailure 2
#ifndef NO_CURL #ifndef NO_CURL
mapM_ (\ name -> results <- mapM (\ name ->
do do
input_data <- Rapi.loadData name input_data <- Rapi.loadData name
writeData nlen name opts (processData input_data) writeData nlen name opts (processData input_data)
) clusters ) clusters
when (not $ all id results) $ exitWith (ExitFailure 2)
#else #else
when (not $ null clusters) $ do when (not $ null clusters) $ do
putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters" putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment