Skip to content

Docker_image.present in same highstate as pip docker module that is required fails the first time. #54332

Closed

Description

@devnullroots

Description of Issue

I am trying to install a docker_image.present state in the same highstate while having pip.installed docker on a pre-requisite sls and it keeps failing on the first run. I have reload_modules: true on the pip.install otherwise it fails from the virtual function that can't find the docker python module.

Setup

Here's my docker_image.present

site_image:
  docker_image.present:
    - name: site
    - tag: stage 
    - build: /srv/site_test
    - dockerfile: Dockerfile
    - require: 
      - sls: docker_engine
    - watch: 
      - git: site_repo

and my docker_engine sls

 include: 
  - generic.apt
  - generic.pip

docker_repo:
  pkgrepo.managed: 
    - name: deb https://download.docker.com/linux/ubuntu bionic stable
    - key_url: "https://download.docker.com/linux/ubuntu/gpg"
    - file: /etc/apt/sources.list.d/docker.list
    - require: 
      - sls: generic.apt

docker_ce:
  pkg.installed:
    - pkgs: 
      - docker-ce:  5:18.09.0~3-0~ubuntu-bionic
      - docker-ce-cli:  5:18.09.0~3-0~ubuntu-bionic
      - containerd.io: 1.2.5-1
    - require: 
      - pkgrepo: docker_repo

docker_python: 
  pip.installed: 
    - name: docker
    - require: 
      - sls: generic.pip
    - reload_modules: true

Steps to Reproduce Issue

Running the minion highstate will fail with

  Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1933, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1939, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/docker_image.py", line 243, in present
                  image_info = __salt__['docker.inspect_image'](full_image)
                File "/usr/lib/python2.7/dist-packages/salt/modules/dockermod.py", line 1843, in inspect_image
                  ret = _client_wrapper('inspect_image', name)
                File "/usr/lib/python2.7/dist-packages/salt/modules/dockermod.py", line 423, in wrapper
                  __context__['docker.client'] = _get_client(timeout=timeout, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/modules/dockermod.py", line 387, in _get_client
                  ret = docker.APIClient(**client_kwargs)
                File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 190, in __init__
                  self._version = self._retrieve_server_version()
                File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 215, in _retrieve_server_version
                  'Error while fetching server API version: {0}'.format(e)
              DockerException: Error while fetching server API version: Timeout value connect was Timeout(connect=60, read=60, total=None), but it must be an int, float or None.

Running the highstate a second after the docker pip module has been installed, succeeds normally.

Versions Report

master

Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: 4.0.2
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15+ (default, Nov 27 2018, 23:36:35)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5

System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-47-generic
         system: Linux
        version: Ubuntu 18.04 bionic

minion

Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: 4.0.2
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15+ (default, Nov 27 2018, 23:36:35)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5

System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-47-generic
         system: Linux
        version: Ubuntu 18.04 bionic


Activity

  1. Ch3LL commented on Aug 28, 2019

    @Ch3LL
    Contributor

    do you have a state that is starting the docker service? That error makes me think it cannot communicate with the docker service for some reason.

  2. added
    needs-more-info
    on Aug 28, 2019
  3. added this to the Blocked milestone on Aug 28, 2019
  4. devnullroots commented on Aug 29, 2019

    @devnullroots
    Author

    I didn't but I added one as a requisite of the python docker module that you can already see and re-run it. It still fails in the same highstate with the same exception. It seems as if it passes the wrong value to call.

    docker_service:
      service.running:
        - name: docker
        - enable: true
        - require: 
          - pkg: docker_ce
        - watch: 
          - pkg: docker_ce
    docker_python: 
      pip.installed: 
        - name: docker
        - require: 
          - sls: generic.pip
          - pkg: docker_ce
          - service: docker_service
        - reload_modules: true
    
  5. devnullroots commented on Aug 29, 2019

    @devnullroots
    Author

    If I re-run the same highstate after the docker module is installed it passes correctly.

  6. Ch3LL commented on Sep 5, 2019

    @Ch3LL
    Contributor

    I did find this issue: docker/docker-py#2107 (comment)

    can you check if you have urllib3 and requests installed as system packages or pip or both?

  7. stale commented on Jan 7, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-more-infostale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions