Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Read timeout when creating a large image #147

Closed
rokroskar opened this issue Aug 4, 2016 · 16 comments
Closed

Read timeout when creating a large image #147

rokroskar opened this issue Aug 4, 2016 · 16 comments

Comments

@rokroskar
Copy link

I'm creating a large image (~3Gb) and the ansible-container build fails at the very end with

Aborting on container exit...
Stopping ansible_jupyterhub_1 ... done
Exporting built containers as images...
Committing image...
UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

I tried increasing the timeout using environment variables, as described e.g. here but this doesn't seem to have any effect.

Interestingly, if I do a partial build on the first pass by leaving out some components and bringing the image size below ~ 2Gb, it works. I can then add the other components back in building on top of the previous image and this build finishes fine (now composed of the two layers instead of one).

versions:

Docker version 1.12.0, build 8eab29e
docker-compose version 1.7.0, build 0d7bf73

System is mac os x 10.10.5.

@ajayaa
Copy link

ajayaa commented Aug 21, 2016

same issue here!

@chouseknecht
Copy link
Contributor

@rokroskar or @ajayaa I want to make sure we troubleshoot and fix this. Can you please provide some additional information:

  • Are you running Docker Toolbox, Docker for Mac or Docker Engine?
  • Copy of container.yml
  • Copy of main.yml
  • Output from ansible-container --debug version

Thank you for reporting this issue. We definitely want to get it solved. Having the above info will be a big help.

@Wildream
Copy link

Wildream commented Sep 7, 2016

Hello. I'm experiencing the same issue when trying to build an example project included into this repo. When I run ansible-container build for the first time, it seems to build image successfully, but then fails with read timeout on image commit. I'm running bleeding edge version of ansible-container built from this repo + Docker Engine 1.12.1 + docker-compose 1.7.0 on elementary OS Freya (which is basically Ubuntu 14.04).

ansible-container --debug version output (with few things removed for safety reasons):

Ansible Container, version 0.2.0-pre
Linux, os_name, 3.19.0-56-generic, #62~14.04.1-Ubuntu SMP Fri Mar 11 11:03:15 UTC 2016, x86_64
2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] /usr/bin/python
No DOCKER_HOST environment variable found. Assuming UNIX socket at /var/run/docker.sock
{u'Architecture': u'x86_64',
 u'BridgeNfIp6tables': True,
 u'BridgeNfIptables': True,
 u'CPUSet': True,
 u'CPUShares': True,
 u'CgroupDriver': u'cgroupfs',
 u'ClusterAdvertise': u'',
 u'ClusterStore': u'',
 u'Containers': 6,
 u'ContainersPaused': 0,
 u'ContainersRunning': 0,
 u'ContainersStopped': 6,
 u'CpuCfsPeriod': True,
 u'CpuCfsQuota': True,
 u'Debug': False,
 u'DefaultRuntime': u'runc',
 u'DockerRootDir': u'/var/lib/docker',
 u'Driver': u'aufs',
 u'DriverStatus': [[u'Root Dir', u'/var/lib/docker/aufs'],
                   [u'Backing Filesystem', u'extfs'],
                   [u'Dirs', u'51'],
                   [u'Dirperm1 Supported', u'true']],
 u'ExecutionDriver': u'',
 u'ExperimentalBuild': False,
 u'HttpProxy': u'',
 u'HttpsProxy': u'',
 u'ID': <removed>
 u'IPv4Forwarding': True,
 u'Images': 7,
 u'IndexServerAddress': u'https://index.docker.io/v1/',
 u'KernelMemory': True,
 u'KernelVersion': u'3.19.0-56-generic',
 u'Labels': None,
 u'LiveRestoreEnabled': False,
 u'LoggingDriver': u'json-file',
 u'MemTotal': 4053917696,
 u'MemoryLimit': True,
 u'NCPU': 2,
 u'NEventsListener': 0,
 u'NFd': 15,
 u'NGoroutines': 25,
 u'Name': u'os_name',
 u'NoProxy': u'',
 u'OSType': u'linux',
 u'OomKillDisable': True,
 u'OperatingSystem': u'elementary OS Freya',
 u'Plugins': {u'Authorization': None,
              u'Network': [u'bridge', u'null', u'host', u'overlay'],
              u'Volume': [u'local']},
 u'RegistryConfig': {u'IndexConfigs': {u'docker.io': {u'Mirrors': None,
                                                      u'Name': u'docker.io',
                                                      u'Official': True,
                                                      u'Secure': True}},
                     u'InsecureRegistryCIDRs': [u'127.0.0.0/8'],
                     u'Mirrors': None},
 u'Runtimes': {u'runc': {u'path': u'docker-runc'}},
 u'SecurityOptions': [u'apparmor'],
 u'ServerVersion': u'1.12.1',
 u'SwapLimit': False,
 u'Swarm': {u'Cluster': {u'CreatedAt': u'0001-01-01T00:00:00Z',
                         u'ID': u'',
                         u'Spec': {u'CAConfig': {},
                                   u'Dispatcher': {},
                                   u'Orchestration': {},
                                   u'Raft': {},
                                   u'TaskDefaults': {}},
                         u'UpdatedAt': u'0001-01-01T00:00:00Z',
                         u'Version': {}},
            u'ControlAvailable': False,
            u'Error': u'',
            u'LocalNodeState': u'inactive',
            u'Managers': 0,
            u'NodeAddr': u'',
            u'NodeID': u'',
            u'Nodes': 0,
            u'RemoteManagers': None},
 u'SystemStatus': None,
 u'SystemTime': u'2016-09-07T01:34:30.387210545+02:00'}
{u'ApiVersion': u'1.24',
 u'Arch': u'amd64',
 u'BuildTime': u'2016-08-18T05:22:43.932726241+00:00',
 u'GitCommit': u'23cf638',
 u'GoVersion': u'go1.6.3',
 u'KernelVersion': u'3.19.0-56-generic',
 u'Os': u'linux',
 u'Version': u'1.12.1'}

When trying to re-run ansible-container build again on the same example project, it starts failing with these messages:

ansible-container_1  | fatal: [gulp]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1473201379.19-252185516336059 `\" && echo ansible-tmp-1473201379.19-252185516336059=\"` echo $HOME/.ansible/tmp/ansible-tmp-1473201379.19-252185516336059 `\" ), exited with result 1", "unreachable": true}

@j00bar
Copy link
Contributor

j00bar commented Sep 7, 2016

@Wildream - That's a different issue than the one on this ticket. Presently, Docker 1.12 is not supported by Ansible Container.

@rokroskar
Copy link
Author

rokroskar commented Sep 8, 2016

@chouseknecht here you go:

Most of the development was done on Docker for Mac but also tried on CentOS 6 with similar results.

Another oddity is that the build actually completes, the image is there, it's just not tagged properly. So if I tag it by hand to be latest and do ansible-container run it works fine.

main.yml:

- hosts: jupyterhub
  vars:
    yum_packages: [wget, openssl, epel-release, bzip2, sudo, readline-devel]

    yum_epel_packages: [nodejs, npm, python-pip]

    python2_packages: [sqlalchemy, numpy, matplotlib, jupyter, notebook, ipykernel, psycopg2, pandas]

    python3_packages: [sqlalchemy, tornado, jinja2, traitlets, requests, pip, ipykernel, notebook]

    system_pip: /usr/bin/pip

    miniconda_path: /usr/local/miniconda

    conda_py2: "{{miniconda_path}}/bin/conda"

    conda_py3: "{{miniconda_path}}/envs/python35/bin/conda"

    conda_py2_pip: "{{miniconda_path}}/bin/pip"

    conda_py3_pip: "{{miniconda_path}}/envs/python35/bin/pip"

  tasks:

    # basic package install
    - name: install development tools
      yum: name="@development-tools" state=present

    - name: install basic packages
      yum: name={{ item }} state=present
      with_items:
        - "{{yum_packages}}"

    - name: install yum-epel packages
      yum: name={{item}} state=present
      with_items:
        - "{{yum_epel_packages}}"


    # miniconda
    - name: download miniconda installer
      get_url:
        url=https://repo.continuum.io/miniconda/Miniconda2-4.1.11-Linux-x86_64.sh
        dest=/tmp/miniconda.sh
        mode=0755
        checksum="md5:b2af3b9ff39c4a4a812f50cecbafcda6"

    - name: install miniconda
      shell: "/tmp/miniconda.sh -b -p {{miniconda_path}} creates={{miniconda_path}} executable=/bin/bash"

    - name: conda install python2 packages
      conda: name={{item}} state=latest executable={{conda_py2}}
      with_items: "{{python2_packages}}"

    - name: make a python 3 environment
      shell: "{{conda_py2}} create --yes -q -n python35 python=3.5 creates={{miniconda_path}}/envs/python35"

    - name: install python3 packages
      conda: name={{item}} executable={{conda_py3}} state=latest
      with_items: "{{python3_packages}}"

    - name: remove miniconda installer
      file: path=/tmp/miniconda.sh state=absent


    # set up jupyterhub user to run jupyterhub instead of root
    - name: create group shadow
      group: name=shadow state=present

    - name: change permissions on the shadow file
      file: path=/etc/shadow group=shadow mode=g=r

    - name: create jupyterhub user
      user: name=jupyterhub groups=shadow append=yes createhome=no

    - name: set up sudoers
      template: dest=/etc/sudoers src=./sudoers owner=root group=root

    - name: install sudospawner
      pip: executable={{conda_py3_pip}} name=https://github.com/jupyterhub/sudospawner/archive/master.zip


    # jupyterhub
    - name: install http proxy
      npm: name=configurable-http-proxy global=yes

    - name: install jupyterhub
      pip: name=jupyterhub executable={{conda_py3_pip}}

    - name: make jupyterhub directory
      file: path=/usr/local/jupyterhub state=directory owner=jupyterhub group=jupyterhub

    - name: create jupyterhub configuration
      template: dest=/usr/local/jupyterhub/jupyterhub_config.py src=./jupyterhub_config.py owner=jupyterhub group=jupyterhub

    - name: make ssl certs
      shell: openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /usr/local/jupyterhub/jhub.key -out /usr/local/jupyterhub/jhub.cert -batch
      args:
        creates: /usr/local/jupyterhub/jhub.key


    # register python kernels
    - name: register py2 kernel
      shell: "{{miniconda_path}}/bin/python -m ipykernel install"
      args:
        creates: /usr/local/share/jupyter/kernels/python2

    - name: register py3 kernel
      shell: "{{miniconda_path}}/envs/python35/bin/python -m ipykernel install"
      args:
        creates: /usr/local/share/jupyter/kernels/python3


    # create users and make links to /notebooks
    - name: copy notebooks to container volume
      copy: dest=/ src=../files/notebooks mode=u=rwX,g=rX,o=rX

    - name: create user test
      user:
        name: test
        groups: jupyterhub
        append: yes
        shell: /bin/bash

    - name: create user notebook directories
      file: dest=/notebooks/test state=directory owner=test group=jupyterhub

    - name: create links to notebook directory
      file: src=/notebooks dest=/home/{{item}}/notebooks state=link
      with_items:
        - test


    # install stata
    - name: pip install pexpect needed to install stata
      pip: name=pexpect state=latest executable=/usr/bin/pip

    - name: make stata directory
      file: path=/usr/local/stata14 state=directory

    - name: unarchive stata
      unarchive: src=files/Stata14Linux64.tar.gz dest=/usr/local/stata14 creates=/usr/local/stata14/install

    - name: fix stata install file
      lineinfile: dest=/usr/local/stata14/install line="#!/bin/sh" insertbefore=BOF state=present

    - name: install stata
      expect:
        chdir: /usr/local/stata14
        command: /usr/local/stata14/install
        responses:
          "y/n": "y\n"
        creates: /usr/local/stata14/stinit
        timeout: 60

    - name: pip install ipystata
      pip: name=ipystata executable={{conda_py2_pip}}

    - name: install libpng12
      yum: name=libpng12 state=present


    # install R
    - name: install R
      yum: name=R.x86_64 state=present

    - name: pip install rpy2
      pip: name=rpy2 executable={{conda_py2_pip}}

container.yml:

version: "1"
services:
  jupyterhub:
    image: centos
    ports:
     - "9000:8000"
    command: "jupyterhub"
    working_dir: /usr/local/jupyterhub
    user: jupyterhub
    environment:
      PATH: /usr/local/miniconda/envs/python35/bin:$PATH"
   volumes:
     - /notebooks
registries: {}

ansible-container --debug version:

Ansible Container, version 0.1.0
Darwin, id-als-docking-130.ethz.ch, 14.5.0, Darwin Kernel Version 14.5.0: Mon Aug 29 21:14:16 PDT 2016; root:xnu-2782.50.6~1/RELEASE_X86_64, x86_64
2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] /Users/rok/miniconda/bin/python
No DOCKER_HOST environment variable found. Assuming UNIX socket at /var/run/docker.sock
{u'Architecture': u'x86_64',
 u'BridgeNfIp6tables': True,
 u'BridgeNfIptables': True,
 u'CPUSet': True,
 u'CPUShares': True,
 u'CgroupDriver': u'cgroupfs',
 u'ClusterAdvertise': u'',
 u'ClusterStore': u'',
 u'Containers': 1,
 u'ContainersPaused': 0,
 u'ContainersRunning': 0,
 u'ContainersStopped': 1,
 u'CpuCfsPeriod': True,
 u'CpuCfsQuota': True,
 u'Debug': True,
 u'DefaultRuntime': u'runc',
 u'DockerRootDir': u'/var/lib/docker',
 u'Driver': u'aufs',
 u'DriverStatus': [[u'Root Dir', u'/var/lib/docker/aufs'],
                   [u'Backing Filesystem', u'extfs'],
                   [u'Dirs', u'112'],
                   [u'Dirperm1 Supported', u'true']],
 u'ExecutionDriver': u'',
 u'ExperimentalBuild': False,
 u'HttpProxy': u'',
 u'HttpsProxy': u'',
 u'ID': u'I3YK:73X5:NIBR:ES7O:37LW:KH3I:TTQ3:N4CJ:V2YG:LLTQ:2RKC:WJHD',
 u'IPv4Forwarding': True,
 u'Images': 93,
 u'IndexServerAddress': u'https://index.docker.io/v1/',
 u'KernelMemory': True,
 u'KernelVersion': u'4.4.15-moby',
 u'Labels': None,
 u'LiveRestoreEnabled': False,
 u'LoggingDriver': u'json-file',
 u'MemTotal': 4140707840,
 u'MemoryLimit': True,
 u'NCPU': 4,
 u'NEventsListener': 1,
 u'NFd': 17,
 u'NGoroutines': 27,
 u'Name': u'moby',
 u'NoProxy': u'*.local, 169.254/16',
 u'OSType': u'linux',
 u'OomKillDisable': True,
 u'OperatingSystem': u'Alpine Linux v3.4',
 u'Plugins': {u'Authorization': None,
              u'Network': [u'host', u'bridge', u'null', u'overlay'],
              u'Volume': [u'local']},
 u'RegistryConfig': {u'IndexConfigs': {u'docker.io': {u'Mirrors': None,
                                                      u'Name': u'docker.io',
                                                      u'Official': True,
                                                      u'Secure': True}},
                     u'InsecureRegistryCIDRs': [u'127.0.0.0/8'],
                     u'Mirrors': None},
 u'Runtimes': {u'runc': {u'path': u'docker-runc'}},
 u'SecurityOptions': [u'seccomp'],
 u'ServerVersion': u'1.12.0',
 u'SwapLimit': True,
 u'Swarm': {u'Cluster': {u'CreatedAt': u'0001-01-01T00:00:00Z',
                         u'ID': u'',
                         u'Spec': {u'CAConfig': {},
                                   u'Dispatcher': {},
                                   u'Orchestration': {},
                                   u'Raft': {},
                                   u'TaskDefaults': {}},
                         u'UpdatedAt': u'0001-01-01T00:00:00Z',
                         u'Version': {}},
            u'ControlAvailable': False,
            u'Error': u'',
            u'LocalNodeState': u'inactive',
            u'Managers': 0,
            u'NodeAddr': u'',
            u'NodeID': u'',
            u'Nodes': 0,
            u'RemoteManagers': None},
 u'SystemStatus': None,
 u'SystemTime': u'2016-09-08T07:53:43.11136759Z'}
{u'ApiVersion': u'1.24',
 u'Arch': u'amd64',
 u'BuildTime': u'2016-07-28T21:15:28.963402499+00:00',
 u'GitCommit': u'8eab29e',
 u'GoVersion': u'go1.6.3',
 u'KernelVersion': u'4.4.15-moby',
 u'Os': u'linux',
 u'Version': u'1.12.0'}

@procrypt
Copy link
Contributor

@rokroskar , You can increase the docker-compose read timeout.

export DOCKER_CLIENT_TIMEOUT=120
export COMPOSE_HTTP_TIMEOUT=120

I was having the same problem, worked for me.

@CampGareth
Copy link

@procrypt Increasing the timeouts doesn't work here.

System is Ubuntu 16.04.1, Docker Engine's in use. The vivado_install role downloads a 9GB tar.gz of Vivado's installer, untars it, installs it, then deletes the tar and decompressed dir. The resulting image is 15GB.

env variables

COMPOSE_HTTP_TIMEOUT=300
DOCKER_CLIENT_TIMEOUT=300

ansible-container build error

Stopping ansible_vivado_1 ... done
Exporting built containers as images...
Committing image...
UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

container.yml

version: "1"
services:
  vivado:
    image: ubuntu:16.04

registries: {}

main.yml

- name: Install vivado
  hosts: vivado
  gather_facts: no
  vars:
    vivado_version: 2015.4 
  pre_tasks: 
    - raw: apt-get update; apt-get -y install python python-simplejson python-boto s3cmd python-pip
  vars_files:
    - "roles/vivado_install/vars/{{ vivado_version }}.yml"

  roles:
    - jenkins_worker
    - vivado_install

ansible-container --debug version

Ansible Container, version 0.2.0
Linux, ip-172-31-60-233, 4.4.0-45-generic, #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016, x86_64
2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] /usr/bin/python
No DOCKER_HOST environment variable found. Assuming UNIX socket at /var/run/docker.sock
{u'Architecture': u'x86_64',
 u'BridgeNfIp6tables': True,
 u'BridgeNfIptables': True,
 u'CPUSet': True,
 u'CPUShares': True,
 u'CgroupDriver': u'cgroupfs',
 u'ClusterAdvertise': u'',
 u'ClusterStore': u'',
 u'Containers': 3,
 u'ContainersPaused': 0,
 u'ContainersRunning': 1,
 u'ContainersStopped': 2,
 u'CpuCfsPeriod': True,
 u'CpuCfsQuota': True,
 u'Debug': False,
 u'DefaultRuntime': u'runc',
 u'DockerRootDir': u'/var/lib/docker',
 u'Driver': u'overlay',
 u'DriverStatus': [[u'Backing Filesystem', u'extfs']],
 u'ExecutionDriver': u'',
 u'ExperimentalBuild': False,
 u'HttpProxy': u'',
 u'HttpsProxy': u'',
 u'ID': u'AJLM:J4LV:HD5X:KYIB:FMWH:S42D:VICZ:NZZ4:AOZ2:LAOO:LPIO:NQSR',
 u'IPv4Forwarding': True,
 u'Images': 19,
 u'IndexServerAddress': u'https://index.docker.io/v1/',
 u'KernelMemory': True,
 u'KernelVersion': u'4.4.0-45-generic',
 u'Labels': None,
 u'LiveRestoreEnabled': False,
 u'LoggingDriver': u'json-file',
 u'MemTotal': 4142112768,
 u'MemoryLimit': True,
 u'NCPU': 2,
 u'NEventsListener': 0,
 u'NFd': 22,
 u'NGoroutines': 33,
 u'Name': u'ip-172-31-60-233',
 u'NoProxy': u'',
 u'OSType': u'linux',
 u'OomKillDisable': True,
 u'OperatingSystem': u'Ubuntu 16.04.1 LTS',
 u'Plugins': {u'Authorization': None,
              u'Network': [u'host', u'bridge', u'null', u'overlay'],
              u'Volume': [u'local']},
 u'RegistryConfig': {u'IndexConfigs': {u'docker.io': {u'Mirrors': None,
                                                      u'Name': u'docker.io',
                                                      u'Official': True,
                                                      u'Secure': True}},
                     u'InsecureRegistryCIDRs': [u'127.0.0.0/8'],
                     u'Mirrors': None},
 u'Runtimes': {u'runc': {u'path': u'docker-runc'}},
 u'SecurityOptions': [u'apparmor', u'seccomp'],
 u'ServerVersion': u'1.12.1',
 u'SwapLimit': False,
 u'Swarm': {u'Cluster': {u'CreatedAt': u'0001-01-01T00:00:00Z',
                         u'ID': u'',
                         u'Spec': {u'CAConfig': {},
                                   u'Dispatcher': {},
                                   u'Orchestration': {},
                                   u'Raft': {},
                                   u'TaskDefaults': {}},
                         u'UpdatedAt': u'0001-01-01T00:00:00Z',
                         u'Version': {}},
            u'ControlAvailable': False,
            u'Error': u'',
            u'LocalNodeState': u'inactive',
            u'Managers': 0,
            u'NodeAddr': u'',
            u'NodeID': u'',
            u'Nodes': 0,
            u'RemoteManagers': None},
 u'SystemStatus': None,
 u'SystemTime': u'2016-11-09T14:31:52.602136983Z'}
{u'ApiVersion': u'1.24',
 u'Arch': u'amd64',
 u'BuildTime': u'2016-08-18T05:33:38.359262265+00:00',
 u'GitCommit': u'23cf638',
 u'GoVersion': u'go1.6.3',
 u'KernelVersion': u'4.4.0-45-generic',
 u'Os': u'linux',
 u'Version': u'1.12.1'}

@rinatz
Copy link

rinatz commented Nov 15, 2016

docker-compose sets timeout via environment variable on creating docker.Client like this
https://github.com/docker/compose/blob/master/compose/cli/docker_client.py#L44

but ansible-container doesn't so
https://github.com/ansible/ansible-container/blob/develop/container/docker/engine.py#L738

I tried setting timeout to 3000 for now and could commit a image successfully.
rinatz@66017cf

@AndydeCleyre
Copy link

AndydeCleyre commented Nov 15, 2016

This started happening to me today, with a container over 2GB, after I changed the storage driver from devicemapper to overlay2, on Arch Linux. The failure happens during the commit. I bumped up COMPOSE_HTTP_TIMEOUT to 300 in my ansible-container build command, but it still fails and still says that (read timeout=60). Next I'll try hard-coding the timeout as rinatz has demonstrated.

EDIT: Yes, hard-coding the timeout as rinatz demonstrated allowed me to move past the issue for now. (Thanks rinatz!)

@chouseknecht
Copy link
Contributor

Tracking upgrade to Docker 1.12 on #314

@marcusianlevine
Copy link
Contributor

marcusianlevine commented Jul 14, 2017

It looks like this issue was originally resolved by #318, but I'm building a 1.8GB image in ansible-container 0.9.1 and getting the same behavior as this user originally reported - but neither exporting COMPOSE_HTTP_TIMEOUT=3000 to my outer "build" environment nor adding it to the conductor settings environment changes the (read timeout=60) in my error output.

If I add the timeout parameter to the Docker client instantiation in container/docker/engine.py as in the original pull request I am able to build the image.

The reason for the regression seems to be a switch from directly instantiating docker.AutoVersionClient to calling docker.from_env. It's not clear to me why COMPOSE_HTTP_TIMEOUT is not being used by docker-py internally when instantiating a client with from_env, but from_env does support the timeout paramater, so I'll submit a pull request referring to os.environ from container/docker/engine.py to set the timeout parameter with COMPOSE_HTTP_TIMEOUT

ansible-container build

...container builds as expected...

PLAY RECAP *********************************************************************
django                     : ok=19   changed=16   unreachable=0    failed=0

Applied role to service role=ordereddict([('role', 'marcusianlevine.django-container'), ('var_files', ['secrets/defaults.yml', 'env_vars/base.yml', 'env_vars
/rabbitmq.yml', 'env_vars/docker.yml'])]) service=django
Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 360, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 360, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 738, in conductorcmd_build
    with_name=is_last_role)
  File "/_ansible/container/docker/engine.py", line 82, in __wrapped__
    return fn(self, *args, **kwargs)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/docker/engine.py", line 510, in commit_role_as_layer
    return to_commit.commit(**commit_data).id
  File "/usr/local/lib/python2.7/dist-packages/docker/models/containers.py", line 110, in commit
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 128, in commit
    return self._result(self._post_json(u, data=conf, params=params),
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 248, in _post_json
    return self._post(url, data=json.dumps(data2), **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 185, in _post
    return self.post(url, **self._set_request_timeout(kwargs))
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 549, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 516, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ansible-container --debug version

Ansible Container, version 0.9.1
Darwin, ml-c02kc2qxffrp.local, 16.6.0, Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64, x86_64
2.7.11 |Anaconda 4.0.0 (x86_64)| (default, Dec  6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] /Users/mlevine/anaconda/bin/python
{
  "ContainersPaused": 0,
  "Labels": null,
  "CgroupDriver": "cgroupfs",
  "ContainersRunning": 0,
  "ContainerdCommit": {
    "Expected": "cfb82a876ecc11b5ca0977d1733adbe58599088a",
    "ID": "cfb82a876ecc11b5ca0977d1733adbe58599088a"
  },
  "InitBinary": "docker-init",
  "NGoroutines": 30,
  "Swarm": {
    "ControlAvailable": false,
    "NodeID": "",
    "Error": "",
    "RemoteManagers": null,
    "LocalNodeState": "inactive",
    "NodeAddr": ""
  },
  "LoggingDriver": "json-file",
  "OSType": "linux",
  "HttpProxy": "",
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  },
  "DriverStatus": [
    [
      "Backing Filesystem",
      "extfs"
    ],
    [
      "Supports d_type",
      "true"
    ],
    [
      "Native Overlay Diff",
      "true"
    ]
  ],
  "OperatingSystem": "Alpine Linux v3.5",
  "Containers": 1,
  "HttpsProxy": "",
  "BridgeNfIp6tables": true,
  "MemTotal": 2096177152,
  "SecurityOptions": [
    "name=seccomp,profile=default"
  ],
  "Driver": "overlay2",
  "IndexServerAddress": "https://index.docker.io/v1/",
  "ClusterStore": "",
  "InitCommit": {
    "Expected": "949e6fa",
    "ID": "949e6fa"
  },
  "Isolation": "",
  "SystemStatus": null,
  "OomKillDisable": true,
  "ClusterAdvertise": "",
  "SystemTime": "2017-07-14T18:07:14.098177616Z",
  "Name": "moby",
  "CPUSet": true,
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [],
    "Mirrors": [],
    "IndexConfigs": {
      "docker.io": {
        "Official": true,
        "Name": "docker.io",
        "Secure": true,
        "Mirrors": []
      }
    },
    "AllowNondistributableArtifactsHostnames": [],
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  },
  "DefaultRuntime": "runc",
  "ContainersStopped": 1,
  "NCPU": 2,
  "NFd": 18,
  "Architecture": "x86_64",
  "KernelMemory": true,
  "CpuCfsQuota": true,
  "Debug": true,
  "ID": "CQ3I:66GK:DDDB:3OFX:GRIA:43OC:YQZX:2P52:P3OR:I44F:ALPU:HYAJ",
  "IPv4Forwarding": true,
  "KernelVersion": "4.9.31-moby",
  "BridgeNfIptables": true,
  "NoProxy": "",
  "LiveRestoreEnabled": false,
  "ServerVersion": "17.06.0-ce",
  "CpuCfsPeriod": true,
  "ExperimentalBuild": true,
  "MemoryLimit": true,
  "SwapLimit": true,
  "Plugins": {
    "Volume": [
      "local"
    ],
    "Network": [
      "bridge",
      "host",
      "ipvlan",
      "macvlan",
      "null",
      "overlay"
    ],
    "Authorization": null,
    "Log": [
      "awslogs",
      "fluentd",
      "gcplogs",
      "gelf",
      "journald",
      "json-file",
      "logentries",
      "splunk",
      "syslog"
    ]
  },
  "Images": 12,
  "DockerRootDir": "/var/lib/docker",
  "NEventsListener": 1,
  "CPUShares": true,
  "RuncCommit": {
    "Expected": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4",
    "ID": "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
  }
}
{
  "KernelVersion": "4.9.31-moby",
  "Arch": "amd64",
  "BuildTime": "2017-06-23T21:51:55.152028673+00:00",
  "ApiVersion": "1.30",
  "Version": "17.06.0-ce",
  "MinAPIVersion": "1.12",
  "GitCommit": "02c1d87",
  "Os": "linux",
  "Experimental": true,
  "GoVersion": "go1.8.3"
}

chouseknecht pushed a commit that referenced this issue Jul 22, 2017
* adding timeout parameter back to docker client instantiation

* fixing broken variable reference in docker engine
@tzok
Copy link
Contributor

tzok commented Apr 20, 2018

I encounter the same bug even though I use version which contains fixes mentioned in this issue. The minimal example is an Ansible role with single task:

- name: create super big file
  shell: 'dd if=/dev/zero of=/root/huge_file.out bs=4k iflag=fullblock,count_bytes count=7GB'

With such Ansible role, the last step which commits role as a layer (seen it in the traceback), repeatedly end up with error message:

requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

I tried setting environment variable e.g. DOCKER_CLIENT_TIMEOUT=600, but the error message always indicates (read timeout=60).

However, when I set the env. variable to something ridiculously small e.g. DOCKER_CLIENT_TIMEOUT=1, then I get exception with message (read timeout=1), but it occurs in some of the earlier steps of container image building (i.e. not during commiting of the role as a layer).

I looked into the source codes in my Python virtualenv and I am sure that this code reads timeout value from the environment (i.e. pull requests 660, 661).

It seems that for some reason, the last action of creating the layer makes a reset of timeout parameter.

Here is the content of container.yml:

version: "2"
settings:
  conductor:
    base: centos:7
  project_name: something
services:
  installer:
    from: "centos:7"
    roles:
      - installer
registries: {}

The role installer has just the task shown above (dd creating a 7GB file).

Here is the result of ansible-container --debug version:

Ansible Container, version 0.9.2
Linux, octomeron, 4.15.15-1-ARCH, #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018, x86_64
3.6.5 (default, Apr 12 2018, 22:45:43) 
[GCC 7.3.1 20180312] /home/tzok/.../venv/bin/python
{
  "ID": "PDDW:MOKZ:AV2B:JAGH:CVBQ:6UJH:5WUO:6HRQ:FTYZ:TXE7:R2EE:R7X4",
  "Containers": 5,
  "ContainersRunning": 0,
  "ContainersPaused": 0,
  "ContainersStopped": 5,
  "Images": 6,
  "Driver": "btrfs",
  "DriverStatus": [
    [
      "Build Version",
      "Btrfs v4.15.1"
    ],
    [
      "Library Version",
      "102"
    ]
  ],
  "SystemStatus": null,
  "Plugins": {
    "Volume": [
      "local"
    ],
    "Network": [
      "bridge",
      "host",
      "macvlan",
      "null",
      "overlay"
    ],
    "Authorization": null,
    "Log": [
      "awslogs",
      "fluentd",
      "gcplogs",
      "gelf",
      "journald",
      "json-file",
      "logentries",
      "splunk",
      "syslog"
    ]
  },
  "MemoryLimit": true,
  "SwapLimit": true,
  "KernelMemory": true,
  "CpuCfsPeriod": true,
  "CpuCfsQuota": true,
  "CPUShares": true,
  "CPUSet": true,
  "IPv4Forwarding": true,
  "BridgeNfIptables": true,
  "BridgeNfIp6tables": true,
  "Debug": false,
  "NFd": 20,
  "OomKillDisable": true,
  "NGoroutines": 34,
  "SystemTime": "2018-04-20T13:19:08.322069493+02:00",
  "LoggingDriver": "json-file",
  "CgroupDriver": "cgroupfs",
  "NEventsListener": 0,
  "KernelVersion": "4.15.15-1-ARCH",
  "OperatingSystem": "Arch Linux",
  "OSType": "linux",
  "Architecture": "x86_64",
  "IndexServerAddress": "https://index.docker.io/v1/",
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [],
    "AllowNondistributableArtifactsHostnames": [],
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ],
    "IndexConfigs": {
      "docker.io": {
        "Name": "docker.io",
        "Mirrors": [],
        "Secure": true,
        "Official": true
      }
    },
    "Mirrors": []
  },
  "NCPU": 4,
  "MemTotal": 16699285504,
  "GenericResources": null,
  "DockerRootDir": "/var/lib/docker",
  "HttpProxy": "",
  "HttpsProxy": "",
  "NoProxy": "",
  "Name": "octomeron",
  "Labels": [],
  "ExperimentalBuild": false,
  "ServerVersion": "18.03.0-ce",
  "ClusterStore": "",
  "ClusterAdvertise": "",
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  },
  "DefaultRuntime": "runc",
  "Swarm": {
    "NodeID": "",
    "NodeAddr": "",
    "LocalNodeState": "inactive",
    "ControlAvailable": false,
    "Error": "",
    "RemoteManagers": null
  },
  "LiveRestoreEnabled": false,
  "Isolation": "",
  "InitBinary": "docker-init",
  "ContainerdCommit": {
    "ID": "cfd04396dc68220d1cecbe686a6cc3aa5ce3667c",
    "Expected": "cfd04396dc68220d1cecbe686a6cc3aa5ce3667c"
  },
  "RuncCommit": {
    "ID": "4fc53a81fb7c994640722ac585fa9ca548971871",
    "Expected": "4fc53a81fb7c994640722ac585fa9ca548971871"
  },
  "InitCommit": {
    "ID": "949e6fa",
    "Expected": "949e6fa"
  },
  "SecurityOptions": [
    "name=seccomp,profile=default"
  ]
}
{
  "Platform": {
    "Name": ""
  },
  "Components": [
    {
      "Name": "Engine",
      "Version": "18.03.0-ce",
      "Details": {
        "ApiVersion": "1.37",
        "Arch": "amd64",
        "BuildTime": "2018-03-23T01:48:12.000000000+00:00",
        "Experimental": "false",
        "GitCommit": "0520e24302",
        "GoVersion": "go1.10",
        "KernelVersion": "4.15.15-1-ARCH",
        "MinAPIVersion": "1.12",
        "Os": "linux"
      }
    }
  ],
  "Version": "18.03.0-ce",
  "ApiVersion": "1.37",
  "MinAPIVersion": "1.12",
  "GitCommit": "0520e24302",
  "GoVersion": "go1.10",
  "Os": "linux",
  "Arch": "amd64",
  "KernelVersion": "4.15.15-1-ARCH",
  "BuildTime": "2018-03-23T01:48:12.000000000+00:00"
}

@tzok
Copy link
Contributor

tzok commented Apr 20, 2018

Actually, it is even simpler:

  • Ansible task: shell: truncate -s 7G /bigfile
  • Run: ansible-container build --no-container-cache

With ansible-container 0.9.2, regardless of any env. vars., the above example always fails with requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

@Chostakovitch
Copy link

I am experimenting the exact same issue with large containers with ansible-container 0.9.3rc0 and no environment variable could help.

After ansible-container build failed, docker commit <container-id> <repo> works.

Please re-open this issue.

@tzok
Copy link
Contributor

tzok commented May 6, 2018

@Chostakovitch, I have found a solution to this problem. The environment must be set on the conductor image, and not on your machine!

Here are the steps to solve your problem.

Prepare custom conductor image:

git clone https://github.com/ansible/ansible-container.git
echo 'ENV DOCKER_CLIENT_TIMEOUT=600' >> ansible-container/container/docker/templates/conductor-local-dockerfile.j2

Fix for pip v10

sed -i 's/from pip.req import parse_requirements/try:\n    from pip._internal.req import parse_requirements\nexcept ImportError:\n    from pip.req import parse_requirements/g' ansible-container/setup.py

Create virtualenv

virtualenv venv
source venv/bin/activate

Install ansible-container from your own custom directory (note the -e flag)

pip install -e ansible-container[docker]

@Chostakovitch
Copy link

@tzok Thanks a lot, this made the trick for the moment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests