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

nomad job run -json panics after successful registration of a periodic job when Job.Periodic.SpecType is not defined #13844

Closed
tristanpemble opened this issue Jul 19, 2022 · 2 comments

Comments

@tristanpemble
Copy link
Contributor

Nomad version

Nomad v1.3.1

Operating system and Environment details

Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 arm unknown Darwin

Issue

When running an API formatted job file (JSON job) via nomad job run -json, and the job has a periodic spec, job registration succeeds, and then the command panics with a SIGSEGV.

Reproduction steps

Create an API job with a Periodic.Spec, but do not define Periodic.SpecType. Run it with nomad job run -json.

Expected Result

The command completes successfully.

Actual Result

The command panics with a SIGSEGV

Job file (if appropriate)

{
  "Datacenters": [
    "dc1"
  ],
  "ID": "foo",
  "Name": "foo",
  "Periodic": {
    "Spec": "* * * * * *"
  },
  "TaskGroups": [
    {
      "Name": "foo",
      "Tasks": [
        {
          "Config": {
            "args": [
              "hello world"
            ],
            "command": "echo"
          },
          "Driver": "raw_exec",
          "Name": "foo"
        }
      ]
    }
  ],
  "Type": "batch"
}

Nomad Server logs (if appropriate)

    2022-07-19T08:06:51.937-0700 [DEBUG] http: request complete: method=PUT path=/v1/jobs duration="353µs"

Nomad Client logs (if appropriate)

Job registration successful
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x101208e98]

goroutine 1 [running]:
github.com/hashicorp/nomad/api.(*PeriodicConfig).Next(0x140007e14a0, {0x37ea8788, 0xeda68bf8b, 0x0})
	github.com/hashicorp/nomad/api@v0.0.0-20220407202126-2eba643965c4/jobs.go:788 +0x28
github.com/hashicorp/nomad/command.(*JobRunCommand).Run(0x14000724a00, {0x1400004e0a0, 0x2, 0x2})
	github.com/hashicorp/nomad/command/job_run.go:355 +0x1044
github.com/mitchellh/cli.(*CLI).Run(0x140003d7680)
	github.com/mitchellh/cli@v1.1.2/cli.go:262 +0x5c4
main.RunCustom({0x1400004e090, 0x3, 0x3})
	github.com/hashicorp/nomad/main.go:115 +0x3a4
main.Run(...)
	github.com/hashicorp/nomad/main.go:85
main.main()
	github.com/hashicorp/nomad/main.go:81 +0x60

Additional Information

I traced the issue down to the nil pointer here, which is called from this path.

This code is called after the job registration succeeds on the server. I believe the root of the issue is that when submitting an API job via the CLI, it is canonicalized server-side, but not client-side. Registration succeeds on the server, and then this code path is called. It references paths that have not been canonicalized with their default values, and fails.

I am new to this codebase, so unsure I have the best approach, but I am submitting a PR that resolved the issue for me.

@tgross tgross added this to Needs Triage in Nomad - Community Issues Triage via automation Jul 23, 2022
@tgross tgross self-assigned this Jul 25, 2022
@tgross tgross added the theme/api HTTP API and SDK issues label Jul 25, 2022
@tgross tgross moved this from Needs Triage to Triaging in Nomad - Community Issues Triage Jul 25, 2022
@tgross
Copy link
Member

tgross commented Jul 25, 2022

Hi @tristanpemble! Thanks for the PR #13845. I've left some review comments there.

@tgross tgross moved this from Triaging to In Progress in Nomad - Community Issues Triage Jul 25, 2022
@tgross tgross added this to the 1.3.x milestone Jul 25, 2022
@tgross tgross removed this from the 1.3.x milestone Aug 23, 2022
tgross pushed a commit to tristanpemble/nomad that referenced this issue Feb 1, 2023
hc-github-team-nomad-core added a commit that referenced this issue Feb 1, 2023
…nce into release/1.2.x (#16015)

This pull request was automerged via backport-assistant
hc-github-team-nomad-core added a commit that referenced this issue Feb 1, 2023
…nce into release/1.3.x (#16016)

This pull request was automerged via backport-assistant
hc-github-team-nomad-core added a commit that referenced this issue Feb 1, 2023
…nce into release/1.4.x (#16017)

This pull request was automerged via backport-assistant
@tgross
Copy link
Member

tgross commented Feb 1, 2023

Fixed in #13845 which will ship in Nomad 1.5.0 (plus backports)

@tgross tgross closed this as completed Feb 1, 2023
Nomad - Community Issues Triage automation moved this from In Progress to Done Feb 1, 2023
@tgross tgross added this to the 1.5.0 milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants