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
...@@ -56,11 +56,13 @@ import Ganeti.HTools.CLI ...@@ -56,11 +56,13 @@ import Ganeti.HTools.CLI
import Ganeti.HTools.ExtLoader import Ganeti.HTools.ExtLoader
import Ganeti.HTools.Types import Ganeti.HTools.Types
import Ganeti.HTools.Loader import Ganeti.HTools.Loader
import Ganeti.OpCodes (wrapOpCode, setOpComment, OpCode, MetaOpCode)
import Ganeti.Types (fromJobId) import Ganeti.Types (fromJobId)
import Ganeti.Utils import Ganeti.Utils
import qualified Ganeti.Luxi as L import qualified Ganeti.Luxi as L
import Ganeti.Jobs import Ganeti.Jobs
import Ganeti.Version (version)
-- | Options list and functions. -- | Options list and functions.
options :: IO [OptType] options :: IO [OptType]
...@@ -99,6 +101,12 @@ options = do ...@@ -99,6 +101,12 @@ options = do
arguments :: [ArgCompletion] arguments :: [ArgCompletion]
arguments = [] 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 {- | Start computing the solution at the given depth and recurse until
we find a valid solution or we exceed the maximum depth. we find a valid solution or we exceed the maximum depth.
...@@ -205,6 +213,7 @@ execJobSet _ _ _ _ [] = return True ...@@ -205,6 +213,7 @@ execJobSet _ _ _ _ [] = return True
execJobSet master nl il cref (js:jss) = do execJobSet master nl il cref (js:jss) = do
-- map from jobset (htools list of positions) to [[opcodes]] -- map from jobset (htools list of positions) to [[opcodes]]
let jobs = map (\(_, idx, move, _) -> let jobs = map (\(_, idx, move, _) ->
map annotateOpCode $
Cluster.iMoveToJob nl il idx move) js Cluster.iMoveToJob nl il idx move) js
let descr = map (\(_, idx, _, _) -> Container.nameOf il idx) js let descr = map (\(_, idx, _, _) -> Container.nameOf il idx) js
putStrLn $ "Executing jobset for instances " ++ commaJoin descr putStrLn $ "Executing jobset for instances " ++ commaJoin descr
......
...@@ -138,10 +138,10 @@ $(genLuxiOp "LuxiOp" ...@@ -138,10 +138,10 @@ $(genLuxiOp "LuxiOp"
, (luxiReqQueryTags, , (luxiReqQueryTags,
[ pTagsObject ]) [ pTagsObject ])
, (luxiReqSubmitJob, , (luxiReqSubmitJob,
[ simpleField "job" [t| [OpCode] |] ] [ simpleField "job" [t| [MetaOpCode] |] ]
) )
, (luxiReqSubmitManyJobs, , (luxiReqSubmitManyJobs,
[ simpleField "ops" [t| [[OpCode]] |] ] [ simpleField "ops" [t| [[MetaOpCode]] |] ]
) )
, (luxiReqWaitForJobChange, , (luxiReqWaitForJobChange,
[ simpleField "job" [t| JobId |] [ simpleField "job" [t| JobId |]
...@@ -443,7 +443,7 @@ parseSubmitJobResult v = ...@@ -443,7 +443,7 @@ parseSubmitJobResult v =
show (pp_value v) show (pp_value v)
-- | Specialized submitManyJobs call. -- | Specialized submitManyJobs call.
submitManyJobs :: Client -> [[OpCode]] -> IO (ErrorResult [JobId]) submitManyJobs :: Client -> [[MetaOpCode]] -> IO (ErrorResult [JobId])
submitManyJobs s jobs = do submitManyJobs s jobs = do
rval <- callMethod (SubmitManyJobs jobs) s rval <- callMethod (SubmitManyJobs jobs) s
-- map each result (status, payload) pair into a nice Result ADT -- map each result (status, payload) pair into a nice Result ADT
......
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