Nomad v0.10.0-rc1 (c49bf41779d2ee462f46e2f58328e58c51970a83)
Distribution: Ubuntu Xenial 16.04.6
Kernel Version: Linux 4.4.0-165-generic x86_64
Docker Version: 19.03.3, build a872fc2
It appears that variable interpolation (using either node attributes or runtime environment variables) does not work in the meta stanza. I'm not sure whether this is an intended feature or not, but the documentation does suggest variable interpolation should work in the meta stanza.
Moving the meta stanza under the task stanza still results in the same output.
docker inspect on the running container to see env variable outputjob "meta-stanza-test-job" {
type = "service"
datacenters = ["dc1"]
meta {
TEST_NUMBER = 1
TEST_STRING = "string"
# Interpolation here fails for both node attributes (e.g. ${node.datacenter}) and runtime environment variables
TEST_INTERPOLATION = "${NOMAD_DC}-${NOMAD_JOB_NAME}"
}
group "meta-stanza-test-group" {
task "meta-stanza-test-task" {
env {
TEST_NUMBER = "${NOMAD_META_TEST_NUMBER}"
TEST_STRING = "${NOMAD_META_TEST_STRING}"
TEST_INTERPOLATION = "${NOMAD_META_TEST_INTERPOLATION}"
ENV_TEST_INTERPOLATION = "${NOMAD_DC}-${NOMAD_JOB_NAME}"
}
driver = "docker"
config {
image = "registry:latest"
port_map {
http = 5000
}
}
resources {
cpu = 500
memory = 512
network {
mbits = 25
port "http" {
}
}
}
}
}
}
Running docker inspect <container_id> gives:
"Env": [
"ENV_TEST_INTERPOLATION=dc1-meta-stanza-test-job",
"NOMAD_ADDR_http=172.16.1.10:31850",
"NOMAD_ALLOC_DIR=/alloc",
"NOMAD_ALLOC_ID=9f4e46c2-a707-e96b-dd44-f7440111d984",
"NOMAD_ALLOC_INDEX=0",
"NOMAD_ALLOC_NAME=meta-stanza-test-job.meta-stanza-test-group[0]",
"NOMAD_CPU_LIMIT=500",
"NOMAD_DC=dc1",
"NOMAD_GROUP_NAME=meta-stanza-test-group",
"NOMAD_HOST_PORT_http=31850",
"NOMAD_IP_http=172.16.1.10",
"NOMAD_JOB_NAME=meta-stanza-test-job",
"NOMAD_MEMORY_LIMIT=512",
"NOMAD_META_TEST_INTERPOLATION=${NOMAD_DC}-${NOMAD_JOB_NAME}",
"NOMAD_META_TEST_NUMBER=1",
"NOMAD_META_TEST_STRING=string",
"NOMAD_NAMESPACE=default",
"NOMAD_PORT_http=5000",
"NOMAD_REGION=global",
"NOMAD_SECRETS_DIR=/secrets",
"NOMAD_TASK_DIR=/local",
"NOMAD_TASK_NAME=meta-stanza-test-task",
"TEST_INTERPOLATION=${NOMAD_DC}-${NOMAD_JOB_NAME}",
"TEST_NUMBER=1",
"TEST_STRING=string",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
This is correct, the meta stanza does not interpolate variables.
@langmartin verified, just saw this in 0.10.0. I'm confused by your comment, are you saying this is intended behaviors, or are you confirming the issue?
The problem we're seeing is trying to interpret node meta into consul service tags defined in the service stanza. This worked fine in Consul 0.9.6 and earlier. Given this worked before, this should be marked as regression.
Most helpful comment
@langmartin verified, just saw this in 0.10.0. I'm confused by your comment, are you saying this is intended behaviors, or are you confirming the issue?
The problem we're seeing is trying to interpret node meta into consul service tags defined in the service stanza. This worked fine in Consul 0.9.6 and earlier. Given this worked before, this should be marked as regression.