LGTM, thanks
On Wed, Jan 15, 2014 at 10:54 AM, Klaus Aehlig <[email protected]> wrote: > When a job gets canceled while still queued, dequeuing requires > luxid to mark it as cancelled. So provide the necessary pure > function to do so. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/JQueue.hs | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs > index a20cc7f..c847c82 100644 > --- a/src/Ganeti/JQueue.hs > +++ b/src/Ganeti/JQueue.hs > @@ -31,6 +31,7 @@ module Ganeti.JQueue > , InputOpCode(..) > , queuedOpCodeFromMetaOpCode > , queuedJobFromOpCodes > + , cancelQueuedJob > , Timestamp > , noTimestamp > , currentTimestamp > @@ -195,6 +196,17 @@ queuedJobFromOpCodes jobid ops = do > setReceivedTimestamp :: Timestamp -> QueuedJob -> QueuedJob > setReceivedTimestamp ts job = job { qjReceivedTimestamp = Just ts } > > +-- | Set the state of a QueuedOpCode to canceled. > +cancelOpCode :: Timestamp -> QueuedOpCode -> QueuedOpCode > +cancelOpCode now op = > + op { qoStatus = OP_STATUS_CANCELED, qoEndTimestamp = Just now } > + > +-- | Transform a QueuedJob that has not been started into its canceled > form. > +cancelQueuedJob :: Timestamp -> QueuedJob -> QueuedJob > +cancelQueuedJob now job = > + let ops' = map (cancelOpCode now) $ qjOps job > + in job { qjOps = ops', qjEndTimestamp = Just now} > + > -- | Job file prefix. > jobFilePrefix :: String > jobFilePrefix = "job-" > -- > 1.8.5.2 > >
