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

Update Nomad API to latest Version #242

Closed
JanMa opened this issue Aug 6, 2021 · 4 comments
Closed

Update Nomad API to latest Version #242

JanMa opened this issue Aug 6, 2021 · 4 comments

Comments

@JanMa
Copy link

JanMa commented Aug 6, 2021

Hello,

this driver pins the Nomad API package to version 1.1.0. This version unfortunately does not support some of the new settings introduced in Nomad 1.1.0, support was only added in version 1.1.3. For example you currently can't specify on_update in a service or check block.

Terraform Version

Terraform v1.0.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/nomad v1.4.15

Nomad Version

Name         Address           Port   Status  Leader  Protocol  Build  Datacenter  Region
infra-1.de  172.24.124.52  4648  alive   false   2         1.1.1  gce-int     de
infra-2.de  172.24.124.29  4648  alive   false   2         1.1.1  gce-int     de
infra-3.de  172.24.124.27  4648  alive   true    2         1.1.1  gce-int     de

Affected Resource(s)

  • nomad_job

Terraform Configuration Files

resource "nomad_job" "example" {
  jobspec = <<EOT
job "example" {
  datacenters = ["gce-int"]

  group "cache" {
    network {
      port "db" {
        to = 6379
      }
    }

    service {
      name = "example"
      port = "db"
      task = "redis"
      on_update = "ignore"
    }
    task "redis" {
      driver = "docker"

      config {
        image = "redis:3.2"

        ports = ["db"]
      }

      resources {
        cpu    = 500
        memory = 256
      }
    }
  }
}
EOT
}

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Error: error parsing jobspec: error parsing 'job': 1 error occurred:
      * group: 'cache', service (0): invalid key: on_update



  with nomad_job.example,
  on jobs.tf line 59, in resource "nomad_job" "example":
  59: resource "nomad_job" "example" {

Expected Behavior

The job should have been deployed. on_update is a valid key in a service block.

Actual Behavior

The job failed to be parsed

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Configure your Nomad provider to point at your DC and adjust it in the jobspec
  2. terraform apply
@lgfa29
Copy link
Contributor

lgfa29 commented Aug 6, 2021

Thank you @JanMa, we'll get an updated version out soon!

@lgfa29
Copy link
Contributor

lgfa29 commented Aug 10, 2021

I was updating the Nomad version, but I think there aren't any significant changes that would impact the provider 🤔

In your specific case, the on_update service attribute was added in Nomad 1.1.0 readiness check, so it's already supported by the provider.

I think that what you are missing is enabling the HCL2 parser. This is required since new fields are only added to this parser. To maintain backwards compatibility, we chose to have this not be the default.

New fields are now being ported to the v1 parser (hashicorp/nomad#10931), so they will be supported in future releases once this work is out.

Give it a try with HCL2 and let us know if the problem persists.

@JanMa
Copy link
Author

JanMa commented Aug 10, 2021

Hey @lgfa29,

thanks for looking into this. I can confirm that if I set the following in the job resource, everything works:

hcl2 {
  enabled = true
}

Maybe you can make it a bit more clear in the docs that job spec fields that were introduced with version 1.1.0 do not work with the v1 parser.

@JanMa JanMa closed this as completed Aug 10, 2021
@lgfa29
Copy link
Contributor

lgfa29 commented Aug 19, 2021

Good point 🙂

#245

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

No branches or pull requests

2 participants