kitchen-docker: SSH connection failed

I’m running into an issue where is appears test-kitchen isn’t waiting long enough to SSH when I’m using /sbin/init for my run_command. If I wait a couple of second, I can then ssh into the instance. Is this something that can be addressed by kitchen-docker or are there any workarounds I might employ?

I’m trying to solve the problem of runit not starting when the package has been installed. On Debian systems, which I’m testing on, it starts via the inittab and the runit cookbook handles this by issuing a telinit once the package is installed.

$ sudo kitchen converge
-----> Starting Kitchen (v1.2.1)
-----> Creating <default-debian-74>...
       Step 0 : FROM dgivens/wheezy
        ---> f8c92d987c7a
       Step 1 : ENV DEBIAN_FRONTEND noninteractive
        ---> Using cache
        ---> 47cd72727fd3
       Step 2 : RUN dpkg-divert --local --rename --add /sbin/initctl
        ---> Using cache
        ---> 68a0adca627d
       Step 3 : RUN ln -sf /bin/true /sbin/initctl
        ---> Using cache
        ---> 22aa8539b9a5
       Step 4 : RUN apt-get update
        ---> Using cache
        ---> e7a978183de9
       Step 5 : RUN apt-get install -y sudo openssh-server curl lsb-release
        ---> Using cache
        ---> c3c4b40c5f5f
       Step 6 : RUN mkdir -p /var/run/sshd
        ---> Using cache
        ---> 44186f2bdfc1
       Step 7 : RUN useradd -d /home/kitchen -m -s /bin/bash kitchen
        ---> Using cache
        ---> 7bd45f37b4a4
       Step 8 : RUN echo kitchen:kitchen | chpasswd
        ---> Using cache
        ---> b20a2a304c97
       Step 9 : RUN echo 'kitchen ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
        ---> Using cache
        ---> bec122d32801
       Successfully built bec122d32801
       e79dce6f1a2b245a4314ece432944f0e93f33783b6e75d76783cbed778b2b652
       [{
           "ID": "e79dce6f1a2b245a4314ece432944f0e93f33783b6e75d76783cbed778b2b652",
           "Created": "2014-03-07T13:59:25.340911399Z",
           "Path": "/sbin/init",
           "Args": [],
           "Config": {
        "Hostname": "e79dce6f1a2b",
        "Domainname": "",
        "User": "",
        "Memory": 0,
        "MemorySwap": 0,
        "CpuShares": 0,
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "PortSpecs": null,
        "ExposedPorts": {
            "22/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "HOME=/",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "DEBIAN_FRONTEND=noninteractive"
        ],
        "Cmd": [
            "/sbin/init"
        ],
        "Dns": null,
        "Image": "bec122d32801",
        "Volumes": null,
        "VolumesFrom": "",
        "WorkingDir": "",
        "Entrypoint": null,
        "NetworkDisabled": false,
        "OnBuild": null
           },
           "State": {
        "Running": true,
        "Pid": 12513,
        "ExitCode": 0,
        "StartedAt": "2014-03-07T13:59:25.491002705Z",
        "FinishedAt": "0001-01-01T00:00:00Z",
        "Ghost": false
           },
           "Image": "bec122d328011c78d9fe642c0b8d858894c9a5271da51b465831a6e718c935a2",
           "NetworkSettings": {
        "IPAddress": "172.17.0.2",
        "IPPrefixLen": 16,
        "Gateway": "172.17.42.1",
        "Bridge": "docker0",
        "PortMapping": null,
        "Ports": {
            "22/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "49195"
                }
            ]
        }
           },
           "ResolvConfPath": "/etc/resolv.conf",
           "HostnamePath": "/var/lib/docker/containers/e79dce6f1a2b245a4314ece432944f0e93f33783b6e75d76783cbed778b2b652/hostname",
           "HostsPath": "/var/lib/docker/containers/e79dce6f1a2b245a4314ece432944f0e93f33783b6e75d76783cbed778b2b652/hosts",
           "Name": "/dreamy_davinci5",
           "Driver": "aufs",
           "Volumes": {},
           "VolumesRW": {},
           "HostConfig": {
        "Binds": null,
        "ContainerIDFile": "",
        "LxcConf": [],
        "Privileged": false,
        "PortBindings": {
            "22/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "49195"
                }
            ]
        },
        "Links": null,
        "PublishAllPorts": false
           }
       }]
       Finished creating <default-debian-74> (0m0.55s).
-----> Converging <default-debian-74>...
       Preparing files for transfer
       Resolving cookbook dependencies with Berkshelf 2.0.14...
       Removing non-cookbook files before transfer
       Preparing data bags
       Preparing environments
       Preparing encrypted data bag secret
       [SSH] connection failed, retrying (#<Net::SSH::Disconnect: connection closed by remote host>)
       [SSH] connection failed, retrying (#<Net::SSH::Disconnect: connection closed by remote host>)
$$$$$$ [SSH] connection failed, terminating (#<Net::SSH::Disconnect: connection closed by remote host>)
>>>>>> Converge failed on instance <default-debian-74>.
>>>>>> Please see .kitchen/logs/default-debian-74.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: connection closed by remote host
>>>>>> ----------------------
daniel.givens@jenkins-n02:~/fusion$ ssh kitchen@localhost -p 49195
The authenticity of host '[localhost]:49195 ([127.0.0.1]:49195)' can't be established.
ECDSA key fingerprint is 84:80:c6:6b:86:bd:47:ed:35:53:0c:e2:99:07:bd:99.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:49195' (ECDSA) to the list of known hosts.
kitchen@localhost's password: 
Linux e79dce6f1a2b 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
kitchen@e79dce6f1a2b:~$ 

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

+1

-----> Starting Kitchen (v1.15.0)
-----> Creating <default-centos-73>...
       Sending build context to Docker daemon 24.58 MB
       Step 1/7 : FROM centos:7
        ---> 67591570dd29
       Step 2/7 : MAINTAINER "msameera" <sameer@mail.com>
        ---> Using cache
        ---> dfeeb2440e5a
       Step 3/7 : ENV container docker
        ---> Using cache
        ---> 3cdba08c07a6
       Step 4/7 : EXPOSE 32773
        ---> Running in 583109b9c836
        ---> 779a403e4c47
       Removing intermediate container 583109b9c836
       Step 5/7 : RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); rm -f /lib/systemd/system/multi-user.target.wants/*;rm -f /etc/systemd/system/*.wants/*;rm -f /lib/systemd/system/local-fs.target.wants/*; rm -f /lib/systemd/system/sockets.target.wants/*udev*; rm -f /lib/systemd/system/sockets.target.wants/*initctl*; rm -f /lib/systemd/system/basic.target.wants/*;rm -f /lib/systemd/system/anaconda.target.wants/*;
        ---> Running in 2451fba617e7
        ---> 2bcb0ff84da1
       Removing intermediate container 2451fba617e7
       Step 6/7 : VOLUME /sys/fs/cgroup
        ---> Running in 0166c6ef6be3
        ---> 509d6f7a7309
       Removing intermediate container 0166c6ef6be3
       Step 7/7 : CMD /usr/sbin/init
        ---> Running in fd5db50d5441
        ---> 2e0bda625ddc
       Removing intermediate container fd5db50d5441
       Successfully built 2e0bda625ddc
       f65e491a3cd55b21cdf56f0bbc308776ae82f0ad9fa7256fcf3d74d2a53e276e
       0.0.0.0:32774
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds
       Waiting for SSH service on localhost:32774, retrying in 3 seconds