Commit 363dc9d6 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Provide a function to compute the canceled version of a job



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: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 47c3c7b1
......@@ -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-"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment