diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs index e6a63322d3aae517ea5755656424a03ee13431d6..956d31827eb687c3744ef3cfb68573439418fc24 100644 --- a/htools/Ganeti/HTools/Program/Hbal.hs +++ b/htools/Ganeti/HTools/Program/Hbal.hs @@ -196,8 +196,8 @@ execJobSet master nl il cref (js:jss) = do descr = map (\(_, idx, _, _) -> Container.nameOf il idx) js logfn = putStrLn . ("Got job IDs" ++) . commaJoin . map (show . fromJobId) putStrLn $ "Executing jobset for instances " ++ commaJoin descr - jrs <- bracket (L.getClient master) L.closeClient - (\client -> Jobs.execJobsWait client jobs logfn) + jrs <- bracket (L.getClient master) L.closeClient $ + Jobs.execJobsWait jobs logfn case jrs of Bad x -> return $ Bad x Ok x -> if null failures diff --git a/htools/Ganeti/Jobs.hs b/htools/Ganeti/Jobs.hs index e35f928e8ad66e37095bebeb7b54a73096492cc8..7990a77bc009965bc04cbdef57afd18d2f192898 100644 --- a/htools/Ganeti/Jobs.hs +++ b/htools/Ganeti/Jobs.hs @@ -38,22 +38,22 @@ import Ganeti.Types -- | Executes a set of jobs and waits for their completion, returning their -- status. -execJobsWait :: L.Client -- ^ The Luxi client - -> [[MetaOpCode]] -- ^ The list of jobs +execJobsWait :: [[MetaOpCode]] -- ^ The list of jobs -> ([L.JobId] -> IO ()) -- ^ Post-submission callback + -> L.Client -- ^ The Luxi client -> IO (Result [(L.JobId, JobStatus)]) -execJobsWait client opcodes callback = do +execJobsWait opcodes callback client = do jids <- L.submitManyJobs client opcodes case jids of Bad e -> return . Bad $ "Job submission error: " ++ formatError e Ok jids' -> do callback jids' - waitForJobs client jids' + waitForJobs jids' client -- | Polls a set of jobs at a fixed interval until all are finished -- one way or another. -waitForJobs :: L.Client -> [L.JobId] -> IO (Result [(L.JobId, JobStatus)]) -waitForJobs client jids = do +waitForJobs :: [L.JobId] -> L.Client -> IO (Result [(L.JobId, JobStatus)]) +waitForJobs jids client = do sts <- L.queryJobsStatus client jids case sts of Bad e -> return . Bad $ "Checking job status: " ++ formatError e @@ -61,5 +61,5 @@ waitForJobs client jids = do then do -- TODO: replace hardcoded value with a better thing threadDelay (1000000 * 15) - waitForJobs client jids + waitForJobs jids client else return . Ok $ zip jids sts'