Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run a job that was retrieved through inspect. #10759

Closed
james-masson opened this issue Jun 15, 2021 · 2 comments
Closed

Can't run a job that was retrieved through inspect. #10759

james-masson opened this issue Jun 15, 2021 · 2 comments

Comments

@james-masson
Copy link

Nomad version

v1.1.0

also tried v1.0.3

Operating system and Environment details

Debian 10

Issue

I expect that the job definitions retrieved through nomad job inspect are valid for re-submission

In my use case, I want to stop/start jobs through the CLI

Reproduction steps

nomad job stop foo
nomad job inspect foo > /tmp/new1
nomad job run /tmp/new1

Expected Result

Nomad successfully reschedules the job

Actual Result

Error getting job struct: Error parsing job file from /tmp/new1:
new1:2,5-10: Extraneous JSON object property; No argument or block type is named "Job". Did you mean "job"?
user$  head /tmp/new1
{
    "Job": {
        "Affinities": null,
        "AllAtOnce": false,
        "Constraints": null,
        "ConsulNamespace": null,
        "ConsulToken": "",
        "CreateIndex": 294,
        "Datacenters": [
            "local"
        ],

I took a look at how the UI is doing this, and it seems to submit the job as inspect retrieves it, so I suspect this is the CLI being overly picky about case.

@tgross
Copy link
Member

tgross commented Jun 15, 2021

Hi @james-masson! This looks to be a duplicate of #6758.

For some more context (#6758 (comment)):

  • HCL is currently parsed entirely in the CLI. This is required for HCL2's ability to get environment variables and local files from the CLI's environment.
  • The nomad job run command currently accepts only HCL. There's no particular documentation that says otherwise, but I've opened docs: clarify HCL is parsed in CLI #10141 to make it explicit.
  • The output of nomad job inspect :jobid is the JSON jobs output. This is round-trippable to the Create Job HTTP API. (There's an integration test demonstrating this behavior as far back as e13f868 in 2017).
  • The output of the nomad job inspect -json :jobid command is the Read Job HTTP API output. This is not round-trippable to the Create Job HTTP API. This flag was added back in Support nomad CLI output with JSON and template format  #1503 but it's not super clear what this gets you over leaving it out.
  • The only difference between the two is the Job wrapper in the JSON. See the examples below for a very simple workaround which should be feasible for any context in which you're manipulating JSON anyways.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants