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

hcl: difference between HCLv1 and HCLv2 when utilising Docker labels #11759

Closed
jrasell opened this issue Jan 3, 2022 · 1 comment
Closed
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/hcl type/bug

Comments

@jrasell
Copy link
Member

jrasell commented Jan 3, 2022

Nomad version

Tested on main at 578a9a616674aca7cf6d3cd055b81b35504f1f7c.

Operating system and Environment details

Reproduced using the Nomad Vagrant machine.

Issue

The behaviour of setting Docker driver config labels on a job specification seems to differ between HCLv1 and HCLv2. The documentation does not work when utilising HCLv2 parsing; I am unsure at this moment whether this is a documentation bug or a bug in the HCLv2 parsing. The error reports comes from this Discuss post; I am unsure if there are other occurrences of this.

HCLv1

In order to set Docker driver config labels using HCLv1 syntax, the following job can be submitted using the nomad job run -hcl1 <job_file>.

job "example" {
  datacenters = ["dc1"]
  group "cache" {
    task "redis" {
      driver = "docker"
      config {
        image = "redis:3.2"
        labels { "this.is.a.label.key" = "value" }
      }
    }
  }
}

Running this job file when omitting the hcl1 flag, however, results in an error.

Error getting job struct: Failed to parse using HCL 2. Use the HCL 1 parser with `nomad run -hcl1`, or address the following issues:
example.nomad:8,18-19: Argument or block definition required; An argument or block definition is required here.

HCLv2

The following altered jobspec works when submitting the job using the HCLv2 parser.

job "example" {
  datacenters = ["dc1"]
  group "cache" {
    task "redis" {
      driver = "docker"
      config {
        image = "redis:3.2"
        labels = { "this.is.a.label.key" = "value" }
      }
    }
  }
}
@jrasell jrasell added type/bug theme/hcl stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Jan 3, 2022
@schmichael
Copy link
Member

I updated the docs in #24074, so I think we can close this. Let's open a new issue if there's still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/hcl type/bug
Projects
Development

No branches or pull requests

2 participants