Commit 6a2e71d9 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add function to obtain job dependencies



Add a function that computes the list of job ids a job depends
on. This will allow to schedule only those jobs for execution,
where all jobs it depends on have been finalized.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 55433d5b
......@@ -41,6 +41,7 @@ module Ganeti.JQueue
, advanceTimestamp
, setReceivedTimestamp
, extendJobReasonTrail
, getJobDependencies
, opStatusFinalized
, extractOpSummary
, calcJobStatus
......@@ -137,6 +138,11 @@ data InputOpCode = ValidOpCode MetaOpCode -- ^ OpCode was parsed successfully
| InvalidOpCode JSValue -- ^ Invalid opcode
deriving (Show, Eq)
-- | From an InputOpCode obtain the MetaOpCode, if any.
toMetaOpCode :: InputOpCode -> [MetaOpCode]
toMetaOpCode (ValidOpCode mopc) = [mopc]
toMetaOpCode _ = []
-- | JSON instance for 'InputOpCode', trying to parse it and if
-- failing, keeping the original JSValue.
instance Text.JSON.JSON InputOpCode where
......@@ -263,6 +269,14 @@ extendJobReasonTrail job =
qjOps job
}
-- | From a queued job obtain the list of jobs it depends on.
getJobDependencies :: QueuedJob -> [JobId]
getJobDependencies job = do
op <- qjOps job
mopc <- toMetaOpCode $ qoInput op
dep <- fromMaybe [] . opDepends $ metaParams mopc
getJobIdFromDependency dep
-- | Change the priority of a QueuedOpCode, if it is not already
-- finalized.
changeOpCodePriority :: Int -> QueuedOpCode -> QueuedOpCode
......
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