Skip to content

docker_image.present fails first time when python3-docker module is installed #54449

Closed

Description

@golpa

Description of Issue

I'm trying to use docker_image.present but salt fails to detect the module on first state.apply because the required python modules are installed in that run. On second state.apply the module is detected and used. This is even the case with reload_modules: true set.

On the first run I see:

----------
          ID: Docker
    Function: pkg.installed
      Result: True
     Comment: The following packages were installed/updated: python3-docker
              The following packages were already installed: docker-ce
     Started: 16:12:02.098635
    Duration: 1403.352 ms
     Changes:   
              ----------
              python3-docker:
                  ----------
                  new:
                      1.9.0-1
                  old:
              python3-websocket:
                  ----------
                  new:
                      0.37.0-2
                  old:
----------
          ID: Kubernetes Dependency Image k8s.gcr.io/pause
    Function: docker_image.present
        Name: k8s.gcr.io/pause
      Result: False
     Comment: State 'docker_image.present' was not found in SLS 'kube-minion'
              Reason: 'docker_image' __virtual__ returned False: 'docker.version' is not available.
     Changes:

On the minion itself the salt-minion logs have this error:

salt-minion[138912]: [ERROR   ] State 'docker_image.present' was not found in SLS 'kube-minion'
salt-minion[138912]: Reason: 'docker_image' __virtual__ returned False: 'docker.version' is not available.

However, it works on second run:

----------
          ID: Docker
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed and are at the desired version
     Started: 16:29:44.739748
    Duration: 26.875 ms
     Changes:  
----------
          ID: Kubernetes Dependency Image k8s.gcr.io/pause
    Function: docker_image.present
        Name: k8s.gcr.io/pause
      Result: True
     Comment: Image 'k8s.gcr.io/pause:3.1' was pulled
     Started: 16:29:44.859688
    Duration: 1079.729 ms
     Changes:   
              ----------
              Layers:
                  ----------
                  Pulled:
                      - 67ddbfb20a22
              Status:
                  Downloaded newer image for k8s.gcr.io/pause:3.1
              Time_Elapsed:
                  0.4564225673675537
              retcode:
                  0

Setup

I have two state files. docker.sls:

Docker:
  pkg.installed:
    - pkgs:
        - docker-ce: 18.06.1~ce~3-0~debian
        - python3-docker
    - install_recommends: False
    - reload_modules: true

and kube.sls:

include:
  - docker

Kubernetes Dependency Image k8s.gcr.io/pause:
  docker_image.present:
    - name: k8s.gcr.io/pause
    - tag: 3.1
    - reload_modules: True
    - require:
      - pkg: Docker
      - service: Docker
      - pkg: Kubernetes Dependencies

This may be related to #54332 but in that case pip is the installation method and the error message is different.

Steps to Reproduce Issue

  1. Run salt <minion> state.apply
  2. Get Failure
  3. Run salt <minion> state.apply
    Success!

Versions Report

On Master:

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.5.3 (default, Sep 27 2018, 17:25:39)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.9 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-9-amd64
         system: Linux
        version: debian 9.9 

On the Minion (after python3-docker has been installed):

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: 1.9.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.5.3 (default, Sep 27 2018, 17:25:39)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.9 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-9-amd64
         system: Linux
        version: debian 9.9 

Activity

  1. xeacott commented on Oct 30, 2019

    @xeacott
    Contributor

    I'm not reproducing this entirely, getting a different error but may be with my sls file...

    linux:
    ----------
              ID: Docker
        Function: pkg.installed
          Result: True
         Comment: All specified packages are already installed and are at the desired version
         Started: 18:51:18.833487
        Duration: 95.318 ms
         Changes:
    ----------
              ID: Kubernetes Dependency Image k8s.gcr.io/pause
        Function: docker_image.present
            Name: k8s.gcr.io/pause
          Result: False
         Comment: The following requisites were not found:
                                     require:
                                         service: Docker
                                         pkg: Kubernetes Dependencies
         Started: 18:51:18.950491
        Duration: 0.179 ms
         Changes:
    
    Summary for linux
    ------------
    Succeeded: 1
    Failed:    1
    ------------
    Total states run:     2
    Total run time:  95.497 ms
    

    I did use the provided states above

  2. xeacott commented on Oct 30, 2019

    @xeacott
    Contributor

    I probably am missing some kubernetes package

  3. added
    v2019.2
    bug
    P4
    and removed on Oct 30, 2019
  4. xpicio commented on Nov 29, 2019

    @xpicio

    Hello i'm reporting the same issue using docker formula (it seems that in docker formula they use reload_modules: true)

    Here a snippet of my sls file:

    include:
      - docker
    
    internal_network:
      docker_network.present:
        - subnet: 172.20.0.0/16
    
    redis service:
      docker_container.running:
        - name: redis
        - image: registry.***.***/***/redis:v1
        - binds:
          - /opt/redis/data:/data
        - ports:
          - 6379
        - networks:
          - internal_network
          - bridge
        - restart_policy: on-failure:3
        - log_driver: syslog
        - log_opt:
          - syslog-facility: daemon
    

    The error on first run:

    ----------
              ID: internal_network
        Function: docker_network.present
          Result: False
         Comment: State 'docker_network.present' was not found in SLS 'init-gtw'
                  Reason: 'docker_network' __virtual__ returned False: 'docker.version' is not available.
         Changes:
    ----------
              ID: redis service
        Function: docker_container.running
            Name: redis
          Result: False
         Comment: State 'docker_container.running' was not found in SLS 'init-gtw'
                  Reason: 'docker_container' __virtual__ returned False: 'docker.version' is not available.
         Changes:
    ----------
    

    The result on second run:

    ----------
              ID: internal_network
        Function: docker_network.present
          Result: True
         Comment: Network 'internal_network' created
         Started: 01:48:06.168053
        Duration: 157.235 ms
         Changes:
                  ----------
                  created:
                      True
    ----------
              ID: redis service
        Function: docker_container.running
            Name: redis
          Result: True
         Comment: Created container 'redis'
         Started: 01:48:06.453425
        Duration: 12383.978 ms
         Changes:
                  ----------
                  container:
                      ----------
                      Networks:
                          ----------
                          internal_network:
                              ----------
                              Gateway:
                                  ----------
                                  new:
                                      172.20.0.1
                                  old:
                                      None
                              IPAddress:
                                  ----------
                                  new:
                                      172.20.0.2
                                  old:
                                      None
                  container_id:
                      ----------
                      added:
                          128201edd8beb49da5321278b2ae5cf01dd8e36577357a09c0f474cb6936a800
                  image:
                      ----------
                      Layers:
                          ----------
                          Pulled:
                              - e42672a2ca6a
                              - 823e4275fef6
                              - 327e62bcfef7
                              - be5997a801f5
                              - dc62338c8c74
                              - 6c40cc604d8e
                              - 79ed9185c842
                              - c2ad7a3b6c3f
                      Status:
                          Downloaded newer image for registry.***.***/***/redis:v1
                      Time_Elapsed:
                          3.1893012523651123
                      retcode:
                          0
                  state:
                      ----------
                      new:
                          running
                      old:
                          None
    

    Versions on server:

    Salt Version:
               Salt: 2019.2.2
    
    Dependency Versions:
               cffi: 1.11.5
           cherrypy: unknown
           dateutil: 2.2
          docker-py: Not Installed
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.10.3
            libgit2: 0.28.2
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.6.2
       mysql-python: Not Installed
          pycparser: 2.19
           pycrypto: 2.6.1
       pycryptodome: 3.9.4
             pygit2: 0.28.2
             Python: 3.7.5 (default, Oct 17 2019, 12:25:15)
       python-gnupg: Not Installed
             PyYAML: 3.13
              PyZMQ: 18.1.1
               RAET: Not Installed
              smmap: Not Installed
            timelib: 0.2.4
            Tornado: 4.5.3
                ZMQ: 4.3.2
    
    System Versions:
               dist:
             locale: UTF-8
            machine: x86_64
            release: 4.14.138+
             system: Linux
            version: Not Installed
    

    Versions on minion:

    root@ubuntu-18:/tmp# salt-call --versions-report
    Salt Version:
               Salt: 2019.2.2
    
    Dependency Versions:
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 2.6.1
          docker-py: 2.5.1
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.10
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: Not Installed
       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: 3.6.9 (default, Nov  7 2019, 10:44:02)
       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-29-generic
             system: Linux
            version: Ubuntu 18.04 bionic
    
  5. added this to the Approved milestone on Dec 17, 2019
  6. stale commented on Jan 16, 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.

  7. lsh-0 commented on Jan 20, 2020

    @lsh-0

    I'm getting this too on Salt 2018.3

    Salt Version:
               Salt: 2018.3.4
     
    Dependency Versions:
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 2.6.1
          docker-py: 4.1.0
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.10
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: Not Installed
       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: 3.6.9 (default, Nov  7 2019, 10:44:02)
       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-72-generic
             system: Linux
            version: Ubuntu 18.04 bionic
     
    
  8. stale commented on Jan 20, 2020

    @stale

    Thank you for updating this issue. It is no longer marked as stale.

  9. 47 remaining items

  10. removed
    Silicon v3004.0
    on Oct 20, 2021
  11. added
    Phosphorus v3005.0
    on Oct 20, 2021
  12. whytewolf commented on Oct 25, 2021

    @whytewolf
    Collaborator

    I'm having trouble replicating this issue with the latest 3004. the reload_modules seems to have taken without the need to reload and I am not getting the tracepath shown in #54449 (comment) when with python3-requests at 2.21.0 and python3-docker installed with pkg.installed at 3.4.1 on debian 10.

    Can someone give a full testcase that replicates the issue?

  13. dmurphy18 commented on Jan 14, 2022

    @dmurphy18
    Contributor

    There is no response to the issue for some months, if none is received soon, the issue will be closed as considered dormant, and no longer relevant.

  14. DaAwesomeP commented on Feb 2, 2022

    @DaAwesomeP
    Contributor

    @whytewolf where did you install the python3-docker module from? Did you install the Debian-provided Docker or the one from the Docker APT repo?

  15. whytewolf commented on Feb 2, 2022

    @whytewolf
    Collaborator

    docker apt doesn't supply python3-docker https://download.docker.com/linux/debian/dists/buster/pool/stable/amd64/ that can only come from the debian repos.

    but i did use the docker apt repos for docker itself

    for the record. I also run a debian 11 system that has a pip installed version of docker. that runs fine. without issue.

  16. whytewolf commented on Feb 14, 2022

    @whytewolf
    Collaborator

    Closing this issue since no one has been able to give a test case that fails, and I have tried the suggested test cases. as well as some things not suggested in an attempt to get it to fail. If you are still having this issue with a 3004 or later version then please open a new ticket.

  17. keithpjolley commented on Aug 23, 2022

    @keithpjolley

    When trying to use the docker_container.running state the 'docker.version' not available error hit. Resolved by reading the fine manual which says to run salt minion pip.install docker. After this the error went away. Will put that as a prerequisite in the .sls file.

  18. markdueck1 commented on Oct 12, 2022

    @markdueck1

    I have recently run into this on raspbian bullseye, with the latest salt (3005.1). This time the pip docker version 6 is the issue, downgrading it to 5.0.3 fixes the issue for me.

  19. whytewolf commented on Oct 12, 2022

    @whytewolf
    Collaborator

    I have recently run into this on raspbian bullseye, with the latest salt (3005.1). This time the pip docker version 6 is the issue, downgrading it to 5.0.3 fixes the issue for me.

    the issue with docker 6 is not related to this issue. docker 6.0.0 broke how they handle versioning which is how salt determines if a proper docker python module is installed. that is much different than what was causing this issue which is loader issues and python path based.

  20. added a commit that references this issue on Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Phosphorus v3005.0bugseverity-medium

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions