On Fri, Nov 8, 2013 at 5:03 PM, Klaus Aehlig <[email protected]> wrote: > On Fri, Nov 08, 2013 at 04:35:07PM +0100, Michele Tartara wrote: >> On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote: >> > Handle this request by writing the jobs to the >> > queue and inform masterd; masterd will then also >> > distribute the jobs to all master candidates. >> > >> > Signed-off-by: Klaus Aehlig <[email protected]> >> > --- >> > src/Ganeti/Query/Server.hs | 34 +++++++++++++++++++++++++++++++++- >> > 1 file changed, 33 insertions(+), 1 deletion(-) >> > > >> "then" and "else" are indented 3 spaces. It should be 2. >> >> > [...] >> >> Shouldn't the client be closed before exiting this function? > > Interdiff 20/22 Make luxid handle SubmitManyJobs > > diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs > index ae8ba06..72ea253 100644 > --- a/src/Ganeti/Query/Server.hs > +++ b/src/Ganeti/Query/Server.hs > @@ -224,33 +224,34 @@ handleCall qlock cfg (SubmitManyJobs lops) = > do > open <- isQueueOpen > if not open > - then return . Bad . GenericError $ "Queue drained" > - else do > - result_jobids <- allocateJobIds (Config.getMasterCandidates cfg) > - qlock (length lops) > - case result_jobids of > - Bad s -> return . Bad . GenericError $ s > - Ok jids -> do > - jobs <- zipWithM queuedJobFromOpCodes jids lops > - qDir <- queueDir > - write_results <- mapM (writeJobToDisk qDir) jobs > - let annotated_results = zip write_results jids > - succeeded = map snd $ filter (isOk . fst) annotated_results > - when (any isBad write_results) . logWarning > - $ "Writing some jobs failed " ++ show annotated_results > - socketpath <- defaultLuxiSocket > - client <- getClient socketpath > - pickupResults <- mapM (flip callMethod client . PickupJob) > - succeeded > - when (any isBad pickupResults) > - . logWarning . (++) "Failed to notify maserd: " . show > - $ zip succeeded pickupResults > - return . Ok . JSArray > - . map (\(res, jid) -> > - if isOk res > - then showJSON (True, fromJobId jid) > - else showJSON (False, genericResult id (const "") > res)) > - $ annotated_results > + then return . Bad . GenericError $ "Queue drained" > + else do > + result_jobids <- allocateJobIds (Config.getMasterCandidates cfg) > + qlock (length lops) > + case result_jobids of > + Bad s -> return . Bad . GenericError $ s > + Ok jids -> do > + jobs <- zipWithM queuedJobFromOpCodes jids lops > + qDir <- queueDir > + write_results <- mapM (writeJobToDisk qDir) jobs > + let annotated_results = zip write_results jids > + succeeded = map snd $ filter (isOk . fst) annotated_results > + when (any isBad write_results) . logWarning > + $ "Writing some jobs failed " ++ show annotated_results > + socketpath <- defaultLuxiSocket > + client <- getClient socketpath > + pickupResults <- mapM (flip callMethod client . PickupJob) > + succeeded > + closeClient client > + when (any isBad pickupResults) > + . logWarning . (++) "Failed to notify maserd: " . show > + $ zip succeeded pickupResults > + return . Ok . JSArray > + . map (\(res, jid) -> > + if isOk res > + then showJSON (True, fromJobId jid) > + else showJSON (False, genericResult id (const "") > res)) > + $ annotated_results > > handleCall _ _ op = > return . Bad $ > > > -- > Klaus Aehlig > Google Germany GmbH, Dienerstr. 12, 80331 Muenchen > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg > Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores
LGTM, thanks. -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
