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

'job' stanza not found (error parsing non-existent old jobspec for new nomad_job) #209

Closed
Lucretius opened this issue Mar 26, 2021 · 1 comment

Comments

@Lucretius
Copy link

Lucretius commented Mar 26, 2021

Terraform Version

v0.14.9

Nomad Version

v1.0.3

Provider Configuration

Which values are you setting in the provider configuration?

provider "nomad" {}

Environment Variables

Do you have any Nomad specific environment variable set in the machine running Terraform?

NOMAD_TOKEN
NOMAD_ADDR
NOMAD_REGION

Affected Resource(s)

  • nomad_job

Terraform Configuration Files

resource "nomad_job" "test" {
  jobspec = <<EOF

job "docs" {
datacenters = ["us-west-2"]

group "example" {
  network {
    port "http" {
      static = "5678"
    }
  }
  task "server" {
    driver = "docker"

    config {
      image = "hashicorp/http-echo"
      ports = ["http"]
      args = [
        "-listen",
        ":5678",
        "-text",
        "hello world",
      ]
    }
  }
}
}
EOF
}

Debug Output

I've just included the relevant Debug output where the error occurs:

2021-03-25T19:38:14.181Z [DEBUG] plugin.terraform-provider-nomad_v1.4.13_x4: 2021/03/25 19:38:14 error parsing old jobspec
2021-03-25T19:38:14.181Z [DEBUG] plugin.terraform-provider-nomad_v1.4.13_x4: 2021/03/25 19:38:14 <nil>
2021-03-25T19:38:14.181Z [DEBUG] plugin.terraform-provider-nomad_v1.4.13_x4: 2021/03/25 19:38:14 'job' stanza not found
2021/03/25 19:38:15 [DEBUG] nomad_job.test: apply errored, but we're indicating that via the Error pointer rather than returning it: error applying jobspec: invalid character '<' looking for beginning of value
2021/03/25 19:38:15 [ERROR] eval: *terraform.EvalApplyPost, err: error applying jobspec: invalid character '<' looking for beginning of value
2021/03/25 19:38:15 [ERROR] eval: *terraform.EvalSequence, err: error applying jobspec: invalid character '<' looking for beginning of value

Expected Behavior

The nomad job should be placed and run on the cluster

Actual Behavior

The nomad job is net new and it appears this is causing the "old jobspec" check to fail because there is no old jobspec. This code used to work but I did see around 2 months ago, https://github.com/hashicorp/terraform-provider-nomad/blob/main/nomad/resource_job.go#L873 was added to check the old jobspec. I think this is causing issues since my nomad_job did not exist before in my TF state. I did try adding the job manually into Nomad and then letting the Nomad provider try to take over but the state seems to need to already be stored in Terraform for nomad_job to work.

Steps to Reproduce

I included a minimal Nomad configuration, with a minimal example job found in the docs. Then, simply run
terraform apply and the issue will appear - though you will need TF_LOG=DEBUG to actually see the useful error messages.

@Lucretius
Copy link
Author

I am going to close this issue for now, as I think the error message I am getting is actually unrelated to the jobspec, but instead an issue with the fact that my server is behind a proxy which requires header authentication, which is currently not possible with the Nomad provider. I would love to see #203 merged to verify, and will re-open the issue after if the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant