Skip to content
Snippets Groups Projects
Commit 7e723913 authored by Iustin Pop's avatar Iustin Pop
Browse files

Switch luxi submit job calls to use MetaOpCode


This patch changes the luxi submit job calls to use wrapped opcodes,
and therefore it changes Hbal to submit actual meta opcodes. For
nicety, hbal also submits a comment now, showing who generated the
job.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 2746a72c
No related branches found
No related tags found
No related merge requests found
......@@ -56,11 +56,13 @@ import Ganeti.HTools.CLI
import Ganeti.HTools.ExtLoader
import Ganeti.HTools.Types
import Ganeti.HTools.Loader
import Ganeti.OpCodes (wrapOpCode, setOpComment, OpCode, MetaOpCode)
import Ganeti.Types (fromJobId)
import Ganeti.Utils
import qualified Ganeti.Luxi as L
import Ganeti.Jobs
import Ganeti.Version (version)
-- | Options list and functions.
options :: IO [OptType]
......@@ -99,6 +101,12 @@ options = do
arguments :: [ArgCompletion]
arguments = []
-- | Wraps an 'OpCode' in a 'MetaOpCode' while also adding a comment
-- about what generated the opcode.
annotateOpCode :: OpCode -> MetaOpCode
annotateOpCode =
setOpComment ("rebalancing via hbal " ++ version) . wrapOpCode
{- | Start computing the solution at the given depth and recurse until
we find a valid solution or we exceed the maximum depth.
......@@ -205,6 +213,7 @@ execJobSet _ _ _ _ [] = return True
execJobSet master nl il cref (js:jss) = do
-- map from jobset (htools list of positions) to [[opcodes]]
let jobs = map (\(_, idx, move, _) ->
map annotateOpCode $
Cluster.iMoveToJob nl il idx move) js
let descr = map (\(_, idx, _, _) -> Container.nameOf il idx) js
putStrLn $ "Executing jobset for instances " ++ commaJoin descr
......
......@@ -138,10 +138,10 @@ $(genLuxiOp "LuxiOp"
, (luxiReqQueryTags,
[ pTagsObject ])
, (luxiReqSubmitJob,
[ simpleField "job" [t| [OpCode] |] ]
[ simpleField "job" [t| [MetaOpCode] |] ]
)
, (luxiReqSubmitManyJobs,
[ simpleField "ops" [t| [[OpCode]] |] ]
[ simpleField "ops" [t| [[MetaOpCode]] |] ]
)
, (luxiReqWaitForJobChange,
[ simpleField "job" [t| JobId |]
......@@ -443,7 +443,7 @@ parseSubmitJobResult v =
show (pp_value v)
-- | Specialized submitManyJobs call.
submitManyJobs :: Client -> [[OpCode]] -> IO (ErrorResult [JobId])
submitManyJobs :: Client -> [[MetaOpCode]] -> IO (ErrorResult [JobId])
submitManyJobs s jobs = do
rval <- callMethod (SubmitManyJobs jobs) s
-- map each result (status, payload) pair into a nice Result ADT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment