On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote:
> During the transition to the new daemon layout, from step 2
> onwards, luxid will write to the queue but masterd will trigger
> the execution. Therefore, add a new luxi request to tell masterd
> to pick up a job that has already been written to the queue.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  lib/luxi.py                               | 5 +++++
>  lib/server/masterd.py                     | 5 +++++
>  src/Ganeti/Luxi.hs                        | 6 ++++++
>  test/hs/Test/Ganeti/Luxi.hs               | 1 +
>  test/py/ganeti.rapi.testutils_unittest.py | 1 +
>  5 files changed, 18 insertions(+)
>
> diff --git a/lib/luxi.py b/lib/luxi.py
> index 29f3aef..ba97469 100644
> --- a/lib/luxi.py
> +++ b/lib/luxi.py
> @@ -53,6 +53,7 @@ KEY_VERSION = "version"
>  REQ_SUBMIT_JOB = "SubmitJob"
>  REQ_SUBMIT_JOB_TO_DRAINED_QUEUE = "SubmitJobToDrainedQueue"
>  REQ_SUBMIT_MANY_JOBS = "SubmitManyJobs"
> +REQ_PICKUP_JOB = "PickupJob"
>  REQ_WAIT_FOR_JOB_CHANGE = "WaitForJobChange"
>  REQ_CANCEL_JOB = "CancelJob"
>  REQ_ARCHIVE_JOB = "ArchiveJob"
> @@ -78,6 +79,7 @@ REQ_ALL = compat.UniqueFrozenset([
>    REQ_AUTO_ARCHIVE_JOBS,
>    REQ_CANCEL_JOB,
>    REQ_CHANGE_JOB_PRIORITY,
> +  REQ_PICKUP_JOB,
>    REQ_QUERY,
>    REQ_QUERY_CLUSTER_INFO,
>    REQ_QUERY_CONFIG_VALUES,
> @@ -479,6 +481,9 @@ class Client(object):
>    def SetWatcherPause(self, until):
>      return self.CallMethod(REQ_SET_WATCHER_PAUSE, (until, ))
>
> +  def PickupJob(self, job):
> +    return self.CallMethod(REQ_PICKUP_JOB, (job,))
> +
>    def SubmitJob(self, ops):
>      ops_state = map(lambda op: op.__getstate__(), ops)
>      return self.CallMethod(REQ_SUBMIT_JOB, (ops_state, ))
> diff --git a/lib/server/masterd.py b/lib/server/masterd.py
> index 1130e90..04511a2 100644
> --- a/lib/server/masterd.py
> +++ b/lib/server/masterd.py
> @@ -295,6 +295,11 @@ class ClientOps:
>        _LogNewJob(True, job_id, ops)
>        return job_id
>
> +    elif method == luxi.REQ_PICKUP_JOB:
> +      logging.info("Picking up new job from queue")
> +      (job_id, ) = args
> +      queue.PickupJob(job_id)
> +
>      elif method == luxi.REQ_SUBMIT_JOB_TO_DRAINED_QUEUE:
>        logging.info("Forcefully receiving new job")
>        (job_def, ) = args
> diff --git a/src/Ganeti/Luxi.hs b/src/Ganeti/Luxi.hs
> index 570992f..b312ecc 100644
> --- a/src/Ganeti/Luxi.hs
> +++ b/src/Ganeti/Luxi.hs
> @@ -163,6 +163,9 @@ $(genLuxiOp "LuxiOp"
>       , simpleField "prev_log" [t| JSValue |]
>       , simpleField "tmout"    [t| Int     |]
>       ])
> +  , (luxiReqPickupJob,
> +     [ simpleField "job" [t| JobId |] ]
> +    )
>    , (luxiReqArchiveJob,
>       [ simpleField "job" [t| JobId |] ]
>      )
> @@ -394,6 +397,9 @@ decodeCall (LuxiCall call args) =
>                      J.readJSON e
>                    _ -> J.Error "Not enough values"
>                return $ WaitForJobChange jid fields pinfo pidx wtmout
> +    ReqPickupJob -> do
> +              [jid] <- fromJVal args
> +              return $ PickupJob jid
>      ReqArchiveJob -> do
>                [jid] <- fromJVal args
>                return $ ArchiveJob jid
> diff --git a/test/hs/Test/Ganeti/Luxi.hs b/test/hs/Test/Ganeti/Luxi.hs
> index f687b05..26343ad 100644
> --- a/test/hs/Test/Ganeti/Luxi.hs
> +++ b/test/hs/Test/Ganeti/Luxi.hs
> @@ -84,6 +84,7 @@ instance Arbitrary Luxi.LuxiOp where
>        Luxi.ReqWaitForJobChange -> Luxi.WaitForJobChange <$> arbitrary <*>
>                                    genFields <*> pure J.JSNull <*>
>                                    pure J.JSNull <*> arbitrary
> +      Luxi.ReqPickupJob -> Luxi.PickupJob <$> arbitrary
>        Luxi.ReqArchiveJob -> Luxi.ArchiveJob <$> arbitrary
>        Luxi.ReqAutoArchiveJobs -> Luxi.AutoArchiveJobs <$> arbitrary <*>
>                                   arbitrary
> diff --git a/test/py/ganeti.rapi.testutils_unittest.py 
> b/test/py/ganeti.rapi.testutils_unittest.py
> index 841d5ae..7543b5c 100755
> --- a/test/py/ganeti.rapi.testutils_unittest.py
> +++ b/test/py/ganeti.rapi.testutils_unittest.py
> @@ -43,6 +43,7 @@ KNOWN_UNUSED_LUXI = compat.UniqueFrozenset([
>    luxi.REQ_ARCHIVE_JOB,
>    luxi.REQ_AUTO_ARCHIVE_JOBS,
>    luxi.REQ_CHANGE_JOB_PRIORITY,
> +  luxi.REQ_PICKUP_JOB,
>    luxi.REQ_QUERY_EXPORTS,
>    luxi.REQ_QUERY_CONFIG_VALUES,
>    luxi.REQ_QUERY_NETWORKS,
> --
> 1.8.4.1
>

LGTM, thanks.
Michele

-- 
Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to