duplicate `task.config.extra_hosts` to Connect sidecar tasks
- Dominant language
- Go
- Stars
- 17k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 105
Description
### Nomad version
Output from `nomad version`
Nomad v1.1.3 (8c0c8140997329136971e66e4c2337dfcf932692)
### Operating system and Environment details
Rocky Linux 8.4 (Green Obsidian)
Docker version 20.10.8, build 3967b7d
```
# nomad agent-info
client
heartbeat_ttl = 12.695519612s
known_servers = 192.168.0.206:4647
last_heartbeat = 2.751359289s
node_id = 3877b77f-6600-7fa3-eaea-6f1dc36d9128
num_allocations = 27
nomad
bootstrap = true
known_regions = 1
leader = true
leader_addr = 192.168.0.206:4647
server = true
raft
applied_index = 21567
commit_index = 21567
fsm_pending = 0
last_contact = 0
last_log_index = 21567
last_log_term = 26
last_snapshot_index = 16628
last_snapshot_term = 23
latest_configuration = [{Suffrage:Voter ID:192.168.0.206:4647 Address:192.168.0.206:4647}]
latest_configuration_index = 0
num_peers = 0
protocol_version = 2
protocol_version_max = 3
protocol_version_min = 0
snapshot_version_max = 1
snapshot_version_min = 0
state = Leader
term = 26
runtime
arch = amd64
cpu_count = 12
goroutines = 2577
kernel.name = linux
max_procs = 12
version = go1.16.5
serf
coordinate_resets = 0
encrypted = false
event_queue = 0
event_time = 1
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 1
members = 1
query_queue = 0
query_time = 1
vault
token_expire_time = 2021-09-15T19:00:39+02:00
token_ttl = 764h46m6s
tracked_for_revoked = 0
```
### Issue
`task.extra_hosts` is not propagated into the docker containers `/etc/hosts`
### Reproduction steps
- Run Consul Connect enabled nomad with a docker driver
- Execute the job file below
- run `cat /etc/hosts` using either `nomad alloc exec` or `docker exec` on the allocation/container
#### Expected Result
```
[root@63ec9326ae5a /]# cat /etc/hosts
# this file was generated by Nomad
127.0.0.1 localhost
::1 localhost
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# this entry is the IP address and hostname of the allocation
# shared with tasks in the task group's network
172.26.65.239 63ec9326ae5a
# these entries are extra hosts added by the task config
127.0.0.1 freeipa.ingress.dc1.consul
[root@63ec9326ae5a /]#
```
#### Actual Result
```
[root@63ec9326ae5a /]# cat /etc/hosts
# this file was generated by Nomad
127.0.0.1 localhost
::1 localhost
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# this entry is the IP address and hostname of the allocation
# shared with tasks in the task group's network
172.26.65.239 63ec9326ae5a
[root@63ec9326ae5a /]#
```
### Job file (if appropriate)
```hcl
job "freeipa" {
datacenters = ["dc1"]
group "freeipa" {
network {
mode = "bridge"
}
service {
name = "freeipa"
port = "443"
connect {
sidecar_service {}
}
}
task "freeipa" {
resources {
memory = 2000
}
driver = "docker"
config {
image = "freeipa/freeipa-server:centos-8"
args = [ "ipa-server-install", "-U", "-r", "DC1.CONSUL", "--no-ntp" ]
sysctl = {
"net.ipv6.conf.all.disable_ipv6" = "0"
}
extra_hosts = ["freeipa.ingress.dc1.consul:127.0.0.1"]
}
env {
HOSTNAME = "freeipa.ingress.dc1.consul"
PASSWORD = "testtest"
}
}
}
}
```
### Nomad Server logs (if appropriate)
### Nomad Client logs (if appropriate)
See also https://github.com/hashicorp/nomad/issues/7746#issuecomment-898945862
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file or test is named. Start by tracing Docker task setup for Consul Connect sidecars, using the supplied job and checking /etc/hosts in both the allocation and sidecar containers. Done means task.config.extra_hosts is present in the Connect sidecar container as well.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100