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

Fix panic when using invalid JSON jobspec #111

Merged
merged 4 commits into from
May 29, 2020

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented May 28, 2020

Currently, when the input jobspec is in JSON format, but the content doesn't follow the expected Nomad JSON structure, the provider will panic when trying to call the Nomad API.

This PR changes the jobpsec parsing logic to gracefully fail when the in this situation.

It also allows for the JSON input to have a root element so that the provider can handle outputs from the Nomad CLI directly:

$ nomad job run -output jobspec.hcl
{
    "Job": {
        "Stop": null,
        "Region": "us",
...
}

@lgfa29 lgfa29 requested review from cgbaker and jrasell May 28, 2020 22:57
@lgfa29 lgfa29 self-assigned this May 28, 2020
cgbaker
cgbaker previously approved these changes May 29, 2020
nomad/resource_job.go Show resolved Hide resolved
Copy link
Contributor

@cgbaker cgbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lgfa29 lgfa29 merged commit de0dad9 into master May 29, 2020
@lgfa29 lgfa29 deleted the fix-dont-panic-with-invalid-json branch May 29, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants