Open brettplarson opened 2 years ago
Hi @brettplarson.
This is due to a difference between HCLv1 and HCLv2 parsing. Levant currently only supports the former whereas running nomad job run
using the 1.2.6 Nomad binary will use the latter.
I confirmed this using the following example job and commands.
job "example" {
type = "service"
datacenters = ["dc1"]
group "cache" {
network {
port "server" {
to = 9999
static = 39399
}
port "server-pub" {
to = 9998
static = 39398
}
}
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
}
}
}
}
$ nomad run -hcl1 -hcl2-strict=false example.nomad 1 ✘ 09:07:22
Error getting job struct: Error parsing job file from example.nomad:
error parsing 'job': group: network, ports -> Port label does not conform to naming requirements ^[a-zA-Z0-9_]+$
$ nomad run -detach example.nomad INT ✘ 09:09:22
Job registration successful
Evaluation ID: da68d7e0-f0da-7d52-5f7f-346aa7423119
The fix on the Levant side would be to update it to support both HCL1/2, although we don't currently have this roadmapped due to other commitments. The linked Nomad issue is orthogonal to this one and regards the consistency of port validation across the HCL versions.
As an immediate workaround, it is possible to change the port label to use underscores rather than dashes such as port "server_pub" {
.
Description Cannot plan or deploy jobs using levant that otherwise work when I render them and use the nomad CLI.
I have a go template which renders ports from a yaml file however I get the following error when trying to use levant deploy / plan.
Rendering the output and then planning / running works fine, it's something with levant itself that is causing this issue.
even though it seems like levant is no longer maintained, I figure it wouldn't hurt to post this.
Relevant Nomad job specification file YAML:
Template:
What the port section looks like rendered:
Output of
levant version
:Output of
consul version
:Output of
nomad version
:Additional environment details:
n/a
Debug log outputs from Levant: