Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

[FEATURE] Dispatch jobs by name, not by Nomad file #127

@sevagh

Description

@sevagh

Description

I have a use-case where I have a parametrized batch job in Nomad. I extended levant to add a command called levant dispatch, which takes the name of the job.

Help text:

sevagh:levant $ levant dispatch --help
Usage: levant dispatch [options] [JOBNAME]

  Dispatch an instance of a Nomad parametrized job

Arguments:

  JOBNAME name of Nomad parametrized job

General Options:

  -address=<http_address>
    The Nomad HTTP API address including port which Levant will use to make
    calls.

  -log-level=<level>
    Specify the verbosity level of Levant's logs. Valid values include DEBUG,
    INFO, and WARN, in decreasing order of verbosity. The default is INFO.

  -monitor
    Monitor the job until it completes.

  -timeout
    How long to wait ( in seconds ) for jobs to be successful before giving up.
    Only applies to batch type jobs for now. Default is 300 seconds.

I also borrow code heavily from this other PR which added monitoring for batch jobs: #85

Finally, I have a feature that outputs the stdout and stderr from the Nomad job:

stdout, err := l.nomad.AllocFS().Cat(alloc, "alloc/logs/build.stdout.0", nil)
if err != nil {
      logging.Error("levant/dispatch: error getting stdout: %v", err)
      return
}

All of my code uses standard Nomad APIs.

Basically, there's a lot of material in my custom branch that may or may not be valuable to contribute upstream:

  1. Polishing and getting this PR (added in the ability to monitor batch jobs to completion - WIP #85) merged to add monitoring of batch/parametrized jobs
  2. Adding a dispatch command to dispatch named jobs instead of submitting HCL files
  3. Adding the ability to view stdout/stderr from the job

Are any of these interesting? All?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions