Repository navigation
Closed
Labels
P3Priority 3PlatformRelates to OS, containers, platform-based utilities like FS, system based appsState-Modulebugbroken, incorrect, or confusing behaviorfixed-pls-verifyfix is linked, bug author to confirm fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone
Description
Description of Issue/Question
When managing containers, and using network_mode: host, docker will implicitly set the domainname property, and dockerng will continually assume that the config was changed.
Setup
input formula:
registrator:
dockerng.running:
- image: gliderlabs/registrator:latest
- network_mode: host
- command: consul://127.0.0.1:8500
- restart_policy: None
- binds:
- /var/run/docker.sock:/tmp/docker.sockI did a json-dump of the _compare function call args after the original container was already created, and dockerng was deciding whether the current running container config matches the saltstack-specified desired config:
defaults_from_image:
{
"Comment": "",
"Container": "a10857e6f5727fa44d215804137d8339c7035a138e40459ea5467f37cdbcac74",
"DockerVersion": "1.6.2",
"Parent": "",
"Created": "2015-08-14T13:55:52.692476857Z",
"Config": {
"Tty": false,
"Cmd": null,
"Volumes": null,
"Domainname": "",
"WorkingDir": "",
"Image": "3c46b3f46415a9f8dcb7cd7aae1d1f676024f8f35e55f03adfb65db31513b371",
"Hostname": "dcc8924290fe",
"StdinOnce": false,
"Labels": {},
"AttachStdin": false,
"User": "",
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Entrypoint": [
"/bin/registrator"
],
"OnBuild": [],
"AttachStderr": false,
"AttachStdout": false,
"OpenStdin": false
},
"Author": "",
"VirtualSize_Human": "20.0 MiB",
"GraphDriver": {
"Data": {
"DeviceName": "docker-253:0-449439-ee47e2b8eac963e2cb525aeafb290564d9a5064d84432efea75a446225a21271",
"DeviceSize": "42949672960",
"DeviceId": "138"
},
"Name": "devicemapper"
},
"VirtualSize": 20932921,
"Size_Human": "20.0 MiB",
"Os": "linux",
"Architecture": "amd64",
"ContainerConfig": {
"Tty": false,
"Cmd": ["/bin/sh", "-c", "apk-install -t build-deps go git mercurial \t&& cd /go/src/github.com/gliderlabs/registrator \t&& export GOPATH=/go \t&& go get \t&& go build -ldflags \"-X main.Version $(cat VERSION)\" -o /bin/registrator \t&& rm -rf /go \t&& apk del --purge build-deps"],
"Volumes": null,
"Domainname": "",
"WorkingDir": "",
"Image": "3c46b3f46415a9f8dcb7cd7aae1d1f676024f8f35e55f03adfb65db31513b371",
"Hostname": "dcc8924290fe",
"StdinOnce": false,
"Labels": {},
"AttachStdin": false,
"User": "",
"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
"Entrypoint": ["/bin/registrator"],
"OnBuild": [],
"AttachStderr": false,
"AttachStdout": false,
"OpenStdin": false
},
"Size": 20932921,
"RepoDigests": [],
"Id": "sha256:57cbfaed16bf3d2377936a5274b84c5f05dc3fb300f39925e4df0dbf5207260f",
"RepoTags": [
"gliderlabs/registrator:latest"
]
}actual:
{
"ExecIDs": null,
"State": {
"Status": "running",
"Pid": 32012,
"OOMKilled": false,
"Dead": false,
"Paused": false,
"Running": true,
"FinishedAt": "0001-01-01T00:00:00Z",
"Restarting": false,
"Error": "",
"StartedAt": "2016-03-21T22:43:14.408782832Z",
"ExitCode": 0
},
"Config": {
"Tty": false,
"Cmd": ["consul://127.0.0.1:8500"],
"Volumes": {"/tmp/docker.sock": {}},
"Domainname": "local-domain.com",
"WorkingDir": "",
"Image": "gliderlabs/registrator:latest",
"Hostname": "sw-analytics43",
"StdinOnce": false,
"Labels": {},
"AttachStdin": false,
"User": "",
"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
"Entrypoint": ["/bin/registrator"],
"OnBuild": null,
"AttachStderr": true,
"AttachStdout": true,
"OpenStdin": false
},
"ResolvConfPath": "/var/lib/docker/containers/8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a/resolv.conf",
"HostsPath": "/var/lib/docker/containers/8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a/hosts",
"Args": ["consul://127.0.0.1:8500"],
"Driver": "devicemapper",
"Path": "/bin/registrator",
"HostnamePath": "/var/lib/docker/containers/8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a/hostname",
"RestartCount": 0,
"Name": "/registrator",
"Created": "2016-03-21T22:43:09.773123742Z",
"GraphDriver": {
"Data": {
"DeviceName": "docker-253:0-449439-791c7d4069747a8f3180276d401a7e8005a44251084dad9f19f4d617bafbaa1a",
"DeviceSize": "42949672960",
"DeviceId": "170"
},
"Name": "devicemapper"
},
"Mounts": [
{
"RW": true,
"Source": "/var/run/docker.sock",
"Destination": "/tmp/docker.sock",
"Mode": "rw",
"Propagation": "rprivate"
}
],
"ProcessLabel": "",
"NetworkSettings": {
"Bridge": "",
"Networks": {
"host": {
"NetworkID": "<redacted>",
"MacAddress": "",
"GlobalIPv6PrefixLen": 0,
"Links": null,
"GlobalIPv6Address": "",
"IPv6Gateway": "",
"IPAMConfig": null,
"EndpointID": "<redacted>",
"IPPrefixLen": 0,
"IPAddress": "",
"Gateway": "",
"Aliases": null
}
},
"SecondaryIPv6Addresses": null,
"LinkLocalIPv6Address": "",
"HairpinMode": false,
"IPv6Gateway": "",
"SecondaryIPAddresses": null,
"SandboxID": "<redacted>",
"MacAddress": "",
"GlobalIPv6Address": "",
"Gateway": "",
"LinkLocalIPv6PrefixLen": 0,
"EndpointID": "",
"SandboxKey": "/var/run/docker/netns/default",
"GlobalIPv6PrefixLen": 0,
"IPPrefixLen": 0,
"IPAddress": "",
"Ports": {}
},
"AppArmorProfile": "",
"Image": "sha256:<redacted>",
"LogPath": "/var/lib/docker/containers/8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a/8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a-json.log",
"HostConfig": {
"CpuPeriod": 0,
"MemorySwappiness": -1,
"ContainerIDFile": "",
"MemorySwap": 0,
"BlkioDeviceReadIOps": null,
"CpuQuota": 0,
"Dns": null,
"ExtraHosts": null,
"PidsLimit": 0,
"DnsSearch": null,
"Privileged": false,
"Ulimits": null,
"CpusetCpus": "",
"CgroupParent": "",
"BlkioWeight": 0,
"RestartPolicy": {"MaximumRetryCount": 0, "Name": "None"},
"OomScoreAdj": 0,
"BlkioDeviceReadBps": null,
"VolumeDriver": "",
"ReadonlyRootfs": false,
"CpuShares": 0,
"PublishAllPorts": false,
"MemoryReservation": 0,
"BlkioWeightDevice": null,
"ConsoleSize": [0, 0],
"NetworkMode": "host",
"BlkioDeviceWriteBps": null,
"Isolation": "",
"GroupAdd": null,
"Devices": null,
"BlkioDeviceWriteIOps": null,
"Binds": ["/var/run/docker.sock:/tmp/docker.sock:rw"],
"CpusetMems": "",
"KernelMemory": 0,
"UTSMode": "",
"PidMode": "",
"VolumesFrom": null,
"CapDrop": null,
"DnsOptions": null,
"ShmSize": 67108864,
"Links": null,
"IpcMode": "",
"PortBindings": null,
"SecurityOpt": null,
"CapAdd": null,
"Memory": 0,
"OomKillDisable": false,
"LogConfig": {"Config": {}, "Type": "json-file"}
},
"Id": "8cb88415fc74752b381fd8469aa76241d849776205cea658dca06bf38b03891a",
"MountLabel": ""
}create_kwargs:
{
"network_mode": "host",
"binds": {
"/var/run/docker.sock": {"bind": "/tmp/docker.sock", "ro": false}
},
"restart_policy": {"MaximumRetryCount": 0, "Name": "None"},
"command": ["consul://127.0.0.1:8500"],
"volumes": ["/tmp/docker.sock"]
}Versions Report
Salt Version:
Salt: 2015.8.7
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: 0.21.1
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 14.7.0
Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libgit2: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.7
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: centos 7.2.1511 Core
machine: x86_64
release: 3.10.0-327.4.4.el7.x86_64
system: CentOS Linux 7.2.1511 Core
- dockerng state and module patched with from 553ecac.
- docker-py 1.6.0
Metadata
Metadata
Assignees
Labels
P3Priority 3PlatformRelates to OS, containers, platform-based utilities like FS, system based appsState-Modulebugbroken, incorrect, or confusing behaviorfixed-pls-verifyfix is linked, bug author to confirm fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
[-]SaltStack `modules.dockerng` `_compare` does not handle domain properly[/-][+]SaltStack `modules.dockerng` `_compare` does not handle docker implicit Domainname properly (issue when using network_mode: host)[/+]timcharper commentedon Mar 21, 2016
Here's the diff that fixes it for me.
If it looks good, I'll submit as a pull request:
ticosax commentedon Mar 22, 2016
Can you copy paste the log that reports the discrepancies ?
You'd need to run with level
-l debug.Actually the value is supposed to be fetched from the container. Which would solve your issue, theoretically.
ticosax commentedon Mar 22, 2016
I tried to reproduce locally, with
network_mode: hostand I couldn't reproduce.Do you have local patches applied ?
timcharper commentedon Mar 22, 2016
@ticosax I do have local patches applied. Running 2015.8.7, with
states/dockerng.pyandmodules/dockerng.pyfrom 553ecac.You can see the discrepancies from my original report, I've logged the three parameters to
_compare. It expects'', but has'local-domain.com'.I'll work more on a repro case.
ticosax commentedon Mar 23, 2016
Still not clear for me what's wrong, please give me the log output.
timcharper commentedon Mar 23, 2016
I'll send the full log via a message and private gist, to reduce the need to redact so much.
timcharper commentedon Mar 23, 2016
I'm running into a very similar error with
memory_swapticosax commentedon Mar 24, 2016
@timcharper
memory_swapis different fromhostnamebecasuememory_swaphas hadcoded default to0.Next time open a new issue so we can focus on
hostname.BTW I'm still waiting for the logs that report the discrepancies for hostname.
What I need is just an excerpt, something like this.
timcharper commentedon Mar 24, 2016
The issue seemed similar since in both cases defaults being set by Docker were causing saltstack to think the config was modified / not set properly.
ticosax commentedon Mar 24, 2016
I tried to reproduce your use case and still fails to fail.
I think to reproduce it, I need somehow to have a domain name defined on the host server.
I'm using ubuntu14.04 within Vagrant. Can you check your hostname conf and tell me how I could setup hostname the same way ?
Sorry, it is not very clear, but I think you have
<redacted.com>defined somewhere on the host.If you can point me to that file it will help.
rallytime commentedon Mar 24, 2016
I saw that @ticosax submitted a fix related to this issue, but it looks like the original reported bug is still being chased down. Is that right @timcharper?
dverbeek84 commentedon Mar 31, 2016
The patch from @timcharper works for me.
ticosax commentedon Mar 31, 2016
@dverbeek84 maybe it is working for you, but this is not the correct fix, because if user explicitly ask for domainname to be an empty string
domainname:The state will ignore this value and dockerng will become inconsistent.
For you and @timcharper the domainnane is set on the container implicitly by whatever mechanism.
I'd like to track down from were it is coming from so I can reproduce it locally.
FYI the fix is probably
But I'd like to test it locally first. And it is difficult because I can't reproduce it in my environment.
jgmchan commentedon Apr 6, 2016
@ticosax I was having this exact problem. Couldn't reproduce it in my vagrant machine but it blew up in our real environments. Here is what I had to do to reproduce it in vagrant.
/etc/hostnamewith an FQDN. eg.vagrant.example.comhostnameservice:sudo service hostname restartdocker inspect --format '{{ .Config.Domainname }}' <test_container>will show theDomainnameis nowexample.comReference: http://askubuntu.com/questions/158957/how-to-set-the-fully-qualified-domain-name-in-12-04
I've had to temporarily work around this issue by setting
- domainname: "{{ salt['grains.get']('domain') }}"in the state file.Hope this helps.
ticosax commentedon Apr 8, 2016
@jgmchan thank you for those clear steps. It helps me a lot.
I could reproduce and a PR is on its way.
rallytime commentedon Jun 10, 2016
Fixed via #32432