-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Network.dns variable interpolation does not actually work #12780
Comments
@twunderlich-grapl can you try running the job but without using the e.g. dns {
servers = "[${attr.unique.network.ip-address}]"
} |
Hi @shoenig, Looking through the code, #12021 updates interpolateNetworks. However, that's only called in the network_hook preRun function. Looking through that code, all of it seems specific to the hostname. I suspect the issue may be that interpolateNetworks may need to be called elsewhere. That said, I haven't dug through the code in depth yet |
Hmm alright thanks for trying @twunderlich-grapl ... I was hoping it was just an HCL parsing thing. Looks like we'll need to investigate further 🙂 |
@shoenig, As a quick and dirty test I used the interpolateNetworks function elsewhere in the code (See #12817), and running that dns.servers = ["${attr.unique.network.ip-address}"] is interpolated correctly and I get the expected private IP address. Since what I did is clearly not production-code, if someone can weigh in on where the best place to update the code would actually be, I can take this across the finish line |
I was trying to "variable-ize" the docker bridge IP and happened to struggle with this. The following minimal job file shows that the variable interpolation works in the docker's The job "example" {
datacenters = ["dc1"]
group "cache" {
network {
# use either the "dns" block OR the "dns_servers". DO NOT use both
# dns {
# servers = ["${attr.driver.docker.bridge_ip}"] # this DOES NOT work
# }
port "db" {
to = 6379
}
}
task "redis" {
driver = "docker"
config {
image = "redis:3.2"
ports = ["db"]
# dns_servers = ["${attr.driver.docker.bridge_ip}"] # this works
}
resources {
cpu = 500
memory = 256
}
}
}
} |
@shantanugadgil thanks for the find! For anyone who doesn't require bridge mode, its certainly a functional workaround.
If you think option 1 is the way to go, I can put up a PR updating the docs pretty quickly edited to add the notes about bridge mode being a requirement for dns_servers |
My apologies for the delay @twunderlich-grapl, you got us right on the 1.3 release and this fell off my radar. I'll take a look at your PR today. |
No worries, thanks for getting this merged in! |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Nomad version
Output from
nomad version
Nomad v1.3.0-beta.1 (2eba643)
Operating system and Environment details
Linux (Tested on Debian Bullseye on ChromeOS and also Amazon Linux 2 in AWS)
Issue
#12021 does not appear to actually work. Looking at the PR it appears that the interpolated DNS values are never used
EDIT: network dns variable interpolation works when placed within the config stanza, but not within the group.network stanza
Reproduction steps
nomad job run example.nomad (the modified version below)
exec into the container
cat /etc/resolv.conf
No variable interpolation takes place, the variable is just interpretted literally
Expected Result
Actual Result
Instead I just get the variable interpreted as a literal.
Job file (if appropriate)
Using a slightly modified version of example.nomad, the differences being
network.dns.servers = ["${attr.unique.network.ip-address}"]
and network_mode = "bridge"
Nomad Server logs (if appropriate)
Nomad Client logs (if appropriate)
The text was updated successfully, but these errors were encountered: