-
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
Broken NOMAD_HOST_PORT_<label> for "host" mode in Nomad 0.9 #5587
Comments
Hi @ole-lukoe , I wasn't able to reproduce the issue with v0.9.0 (18dd590). The job spec above was failing because the
I commented out that argument (
Can you please post the status of the allocation and the result of |
I have been playing with Nomad 0.9.0 and noticed similar behavior with the docker driver but in my case I am using the default network_mode. I suspect it's something with my Nomad client configuration and how its attempting to fingerprint IP addresses but that is more of a guess at this point. Job file
Job alloc
Verified the container is running.
Docker inspect and exec outputVerify the correct container ID.
Docker exec env output.
Docker inspect output.
Nomad client configurationContainer Linux by CoreOS stable (2023.5.0) Nomad v0.9.0 (18dd590)
Docker version:
Consul version:
|
I had this problem as well when running the client version 0.9.1, but the server version 0.8.4. It resolved itself once I updated the server. |
@dansteen thanks for the info! Turns out I was running a 0.8.7 server and bumping to 0.9.1 resolved the issue as you noted. Thanks again! |
Thanks for raising this and for the hint about 0.8.7 server! I was able to reproduce it and I aim to fix it soon, as we do want to support 0.9 clients against 0.8 servers to ease upgrades (we don't recommend this configuration for long though). |
Fixes #5587 When a nomad 0.9 client is handling an alloc generated by a nomad 0.8 server, we should check the alloc.TaskResources for networking details rather than task.Resources. We check alloc.TaskResources for networking for other tasks in the task group [1], so it's a bit odd that we used the task.Resources struct here. TaskRunner also uses `alloc.TaskResources`[2]. The task.Resources struct in 0.8 was sparsly populated, resulting to storing of 0 in port mapping env vars: ``` vagrant@nomad-server-01:~$ nomad version Nomad v0.8.7 (21a2d93+CHANGES) vagrant@nomad-server-01:~$ nomad server members Name Address Port Status Leader Protocol Build Datacenter Region nomad-server-01.global 10.199.0.11 4648 alive true 2 0.8.7 dc1 global vagrant@nomad-server-01:~$ nomad alloc status -json 5b34649b | jq '.Job.TaskGroups[0].Tasks[0].Resources.Networks' [ { "CIDR": "", "Device": "", "DynamicPorts": [ { "Label": "db", "Value": 0 } ], "IP": "", "MBits": 10, "ReservedPorts": null } ] vagrant@nomad-server-01:~$ nomad alloc status -json 5b34649b | jq '.TaskResources' { "redis": { "CPU": 500, "DiskMB": 0, "IOPS": 0, "MemoryMB": 256, "Networks": [ { "CIDR": "", "Device": "eth1", "DynamicPorts": [ { "Label": "db", "Value": 21722 } ], "IP": "10.199.0.21", "MBits": 10, "ReservedPorts": null } ] } } ``` Also, updated the test values to mimic how Nomad 0.8 structs are represented, and made its result match the non compact values in `TestEnvironment_AsList`. [1] https://github.com/hashicorp/nomad/blob/24e9040b18a4f893e2f353288948a0f7cd9d82e4/client/taskenv/env.go#L624-L639 [2] https://github.com/hashicorp/nomad/blob/master/client/allocrunner/taskrunner/task_runner.go#L287-L303
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
Nomad v0.9.0 (18dd590)
Operating system and Environment details
Ubuntu 16.04
Issue
I'm using ability to allocate random port numbers in "host" networking mode to bind docker containers on LAN interface. But with last release NOMAD_HOST_PORT_ variables are equal to 0.
Desired
$ set | grep NOMAD_HOST_PORT
NOMAD_HOST_PORT_http='27700'
NOMAD_HOST_PORT_tcp='26954'
It works in 0.8.7
Now
$ set | grep NOMAD_HOST_PORT
NOMAD_PORT_http='0'
NOMAD_PORT_tcp='0'
Job file (if appropriate)
The text was updated successfully, but these errors were encountered: