moby: Swarm tasks inconsistently stuck in New state on service creation

Description

Inconsistently, some services will fail to assign some or all of their tasks. For example:

root@qa-swarm-manager1:~# docker service ps uname-echo
ID                  NAME                IMAGE               NODE                                    DESIRED STATE       CURRENT STATE           ERROR               PORTS
1d4qk1owa4q4        uname-echo.1        busybox:latest      qa-swarm-worker1                   Running             Running 5 minutes ago                       
qmyqh3t36qmz        uname-echo.2        busybox:latest                                              Running             New 5 minutes ago                           
ttxzdobi8xu5        uname-echo.3        busybox:latest                                              Running             New 5 minutes ago  

Where there are three worker nodes in total. I have a manager that the service was created on and a worker that the task is not running on running at debug log level and no relevant log messages to the service appear to be logged aside from this on worker2 to learn about the task on worker1 (I presume).

Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.242685624-08:00" level=debug msg="handleEpTableEvent ADD 9a34dae4bd58a72b26d1bf2dd996058ae7776f76d6d72bfc1078fcf1a6ce13cb R:{uname-echo.1.1d4qk1owa4q4ngr9gww0y2yo7 uname-echo pheha2c4cvxmc6xoocqp7b6n8 10
.255.0.104 10.255.0.105 [&PortConfig{Name:,Protocol:TCP,TargetPort:2000,PublishedPort:2000,}] [] [184055cdffca]}"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.242832003-08:00" level=debug msg="addServiceBinding from handleEpTableEvent START for uname-echo 9a34dae4bd58a72b26d1bf2dd996058ae7776f76d6d72bfc1078fcf1a6ce13cb p:0xc422248000 nid:1sxb29yly08nza2lca7k85
8zc skey:{pheha2c4cvxmc6xoocqp7b6n8 2000:2000/TCP}"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.243277282-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -nL DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.253861877-08:00" level=debug msg="/sbin/iptables, [--wait -t filter -nL DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.263331739-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -C DOCKER-INGRESS -j RETURN]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.274421025-08:00" level=debug msg="/sbin/iptables, [--wait -t filter -C DOCKER-INGRESS -j RETURN]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.281857420-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -C OUTPUT -m addrtype --dst-type LOCAL -j DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.289721075-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -C PREROUTING -m addrtype --dst-type LOCAL -j DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.299417738-08:00" level=debug msg="/sbin/iptables, [--wait -t filter -C FORWARD -j DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.308027196-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -C POSTROUTING -m addrtype --src-type LOCAL -o docker_gwbridge -j MASQUERADE]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.318947307-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -nL DOCKER-INGRESS]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.331459121-08:00" level=debug msg="/sbin/iptables, [--wait -t nat -I DOCKER-INGRESS -p tcp --dport 2000 -j DNAT --to-destination 172.18.0.2:2000]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.341649297-08:00" level=debug msg="/sbin/iptables, [--wait -I DOCKER-INGRESS -m state -p tcp --sport 2000 --state ESTABLISHED,RELATED -j ACCEPT]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.353493423-08:00" level=debug msg="/sbin/iptables, [--wait -I DOCKER-INGRESS -p tcp --dport 2000 -j ACCEPT]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.364219644-08:00" level=debug msg="Creating service for vip 10.255.0.104 fwMark 258 ingressPorts []*libnetwork.PortConfig{&libnetwork.PortConfig{Name: \"\",\nProtocol: 0,\nTargetPort: 0x7d0,\nPublishedPor
t: 0x7d0,\n}} in sbox ingress (ingress)"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.466581471-08:00" level=debug msg="addEndpointNameResolution 9a34dae4bd58a72b26d1bf2dd996058ae7776f76d6d72bfc1078fcf1a6ce13cb uname-echo add_service:true sAliases:[] tAliases:[184055cdffca]"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.466685837-08:00" level=debug msg="addContainerNameResolution 9a34dae4bd58a72b26d1bf2dd996058ae7776f76d6d72bfc1078fcf1a6ce13cb uname-echo.1.1d4qk1owa4q4ngr9gww0y2yo7"
Dec 20 08:10:01 qa-swarm-worker2 dockerd[15414]: time="2017-12-20T08:10:01.466712490-08:00" level=debug msg="addServiceBinding from handleEpTableEvent END for uname-echo 9a34dae4bd58a72b26d1bf2dd996058ae7776f76d6d72bfc1078fcf1a6ce13cb"

This is the whole list of services on the cluster:

ID                  NAME                MODE                REPLICAS            IMAGE                                               PORTS
iyebje9w7uli        es-proxy            replicated          2/2                 h3nrik/nginx-ldap:latest                            *:15002->443/tcp
m3orsxa9hwn0        nginx               global              3/3                 nexus:5000/nginx-jdomain:latest   
e9r10puh8vqi        uname-echo          replicated          1/3                 busybox:latest                                      *:2000->2000/tcp

Depending on the order in which the services are created, it may not always be the same service that hits this. I’m not seeing any indication of why it’s failing to progress from New state on these tasks. The uname-echo service has an ingress network port mapped, but is not a member of any other networks.

Steps to reproduce the issue:

  1. Create service on swarm with ingress port mapped.

Describe the results you received:

Some tasks never get assigned to workers and get stuck in “New” status.

Describe the results you expected:

All tasks to be assigned to workers.

Additional information you deem important (e.g. issue happens only occasionally):

uname-echo service inspect: https://gist.github.com/mattlqx/cbf38fef481ffe2d399119c8342511b7 ingress network inspect: https://gist.github.com/mattlqx/f82ba1c9fe64128b96a4a8d75dacd01f

Output of docker version:

Docker version 17.11.0-ce, build 1caf76c

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.11.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: ncmrtjzjdbn2hrxo02lfk2y9i
 Is Manager: true
 ClusterID: 29bbrozr1vt4vtfuwpxawcijb
 Managers: 3
 Nodes: 6
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 172.16.7.224
 Manager Addresses:
  172.16.7.224:2377
  172.16.7.225:2377
  172.16.7.226:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 992280e8e265f491f7a624ab82f3e238be086e49
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-98-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.953GiB
Name: qa-swarm-manager1
ID: HHRF:ZAK7:CTGM:FRIQ:FMGP:CMXE:DTWF:VOTY:PCM5:LOYA:UIG7:U3RP
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 45
 Goroutines: 139
 System Time: 2017-12-20T08:35:15.192929619-08:00
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.): vSphere instances

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 9
  • Comments: 15

Most upvoted comments

@rdehouss & @Danylov-Mykola I suggest to try docker ps -a because I bet there are dead containers that consume IP addresses needed by new instances. Se my previous comments for reasoning.

Maybe it is inappropriate to state here but I’d recommend you to switch to Kubernetes. That is how we have resolved this issue for good in the company I was working at the time.

Are you sure there are no hanging containers? Swarm keeps containers for tasks that have already ended. We had exactly this problem. Writing docker ps showed few container at each node. But writing docker ps -a revealed some stopped container. We rebooted all nodes, but later I tried to lower the task history limit and it pruned dead containers. On manager node execute following command

docker swarm update --task-history-limit=1

See How to clear Docker task history for details.

I honestly did the same. We’ve been running k8s for 2 years now and I’ve haven’t ever been blocked by issues like this.

After few hours we have been able to start the rest of the containers. Our problem was that some services crashed (our internal problem, not related to docker) and as the result tasks remained in history. For that purpose, container is retained on node and it keeps the IP address. We only had /24 network (256 addresses) and suddenly all were taken by both running and exited containers. We have make the network bigger /16 and now we have all containers running. We have also lowered the task history length. I filled bug for inconsistency/ambiguity in documentation of docker Inconsistent overlay network size limits.

Are there gonna be any response from docker team? We have experienced the same issue while having 14 nodes, about 8 overlay networks and groups services that only differs in network presence while having the same docker image. Some of them started, some of them remained in new state. Even after destroying the whole stack and recreating it from scratch, the same services stuck in new state again.

We are using virtual machines and scale sets on Azure and some services are created programmatically. Docker 17.12.