salt icon indicating copy to clipboard operation
salt copied to clipboard

Python exception after update to 2017.7.0 (critical regression)

Open tomlaredo opened this issue 9 years ago • 7 comments

Description of Issue

Python throws an exception on state.apply after update to 2017.7.0. Tris is a critical regression as all was working fine before and now salt is just unusable.

Setup

  • OS: Debian Jessie 8.8 64bits (Proxmox LXC container)
  • Debian Package: 2017.7.0+ds-1
  • Package installed from: http://repo.saltstack.com/apt/debian/8/amd64/latest/ jessie/main amd64 Packages
  • Salt minion version: salt-call 2017.7.0 (Nitrogen)

Steps to Reproduce Issue

# salt-call state.apply test=True --log-level=debug
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/etc/salt/minion.d/minion.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/minion.conf
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/etc/salt/minion.d/minion.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/minion.conf
[DEBUG   ] The `lspci` binary is not available on the system. GPU grains will not be available.
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[DEBUG   ] All tools for virtual hardware identification failed to execute because they do not exist on the system running this instance or the user does not have the necessary permissions to execute them. Grains output might not be accurate.
[INFO    ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[INFO    ] Got list of available master addresses: ['master.salt.mydomain.net', '82.67.71.177', '88.172.135.123', 'xx.xx.xx.xx']
[DEBUG   ] Connecting to master. Attempt 1 of 1
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (2592)
[DEBUG   ] Setting zmq_reconnect_ivl to '2592ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506', 'clear')
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] SaltEvent PUB socket URI: /var/run/salt/minion/minion_event_69ed77ec2a_pub.ipc
[DEBUG   ] SaltEvent PULL socket URI: /var/run/salt/minion/minion_event_69ed77ec2a_pull.ipc
[DEBUG   ] Initializing new IPCClient for path: /var/run/salt/minion/minion_event_69ed77ec2a_pull.ipc
[DEBUG   ] Sending event: tag = salt/auth/creds; data = {'_stamp': '2017-07-19T08:04:11.666262', 'creds': {'publish_port': 4505, 'aes': '4x0Laf1JkIk5agUe4H4qzPv2c9xnGrLp/OSa05jZ98stXL4li47u+X/37bNnoX2dAR38ZTZKjZQ=', 'master_uri': 'tcp://xx.xx.xx.xx:4506'}, 'key': ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506')}
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] Determining pillar cache
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506')
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded state.apply
[DEBUG   ] LazyLoaded grains.get
[DEBUG   ] LazyLoaded saltutil.is_running
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506')
[INFO    ] Loading fresh modules for state activity
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded config.option
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506', 'aes')
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'myserver.mydomain.net', 'tcp://xx.xx.xx.xx:4506')
[DEBUG   ] LazyLoaded highstate.output
local:
    Data failed to compile:
----------
    Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 3629, in call_highstate
    top = self.get_top()
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 3089, in get_top
    tops = self.get_tops()
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2787, in get_tops
    saltenv
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 189, in cache_file
    return self.get_url(path, '', True, saltenv, cachedir=cachedir)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 495, in get_url
    result = self.get_file(url, dest, makedirs, saltenv, cachedir=cachedir)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 1044, in get_file
    hash_server, stat_server = self.hash_and_stat_file(path, saltenv)
TypeError: 'bool' object is not iterable

Versions Report

# salt-call --versions-report
Salt Version:
           Salt: 2017.7.0
 
Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
      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.2
   mysql-python: Not Installed
      pycparser: 2.10
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: debian 8.8 
         locale: UTF-8
        machine: x86_64
        release: 4.4.59-1-pve
         system: Linux
        version: debian 8.8 

tomlaredo avatar Jul 19 '17 08:07 tomlaredo

Here are my observations:

salt/fileclient.py:

    def __hash_and_stat_file(self, path, saltenv='base'):
        '''
        Common code for hashing and stating files
        '''
        try:
            path = self._check_proto(path)
        except MinionError as err:
            if not os.path.isfile(path):
                msg = 'specified file {0} is not present to generate hash: {1}'
                log.warning(msg.format(path, err))
                return {}
            else:
                ret = {}
                hash_type = self.opts.get('hash_type', 'md5')
                ret['hsum'] = salt.utils.get_hash(path, form=hash_type)
                ret['hash_type'] = hash_type
                return ret, list(os.stat(path))
        load = {'path': path,
                'saltenv': saltenv,
                'cmd': '_file_hash_and_stat'}
        return self.channel.send(load)

So it returns either a dict, or a tuple (dict, list) or, something else (self.channel.send). self.channel.send could be many functions whether it is this or that class/transport.

With some prints we found this: salt/fileclient.py 1013: self.opts["transport"] ===> zeromq 1270: self.channel.__class__.__name__ ===> SyncWrapper

salt/transport/zeromq.py 870: # TODO: unit tests! ===> :)

I think this issue is related to commit 94b9ea5 refactoring parts of zeromq transport code. Any idea @kstreee ?

tomlaredo avatar Jul 19 '17 09:07 tomlaredo

Same here. Here my version report:

Salt Version:
       Salt: 2017.7.0

Dependency Versions:
         cffi: Not Installed
     cherrypy: Not Installed
     dateutil: Not Installed
    docker-py: Not Installed
        gitdb: Not Installed
    gitpython: Not Installed
        ioflo: Not Installed
       Jinja2: 2.7.2
      libgit2: Not Installed
      libnacl: Not Installed
     M2Crypto: 0.21.1
         Mako: Not Installed
 msgpack-pure: Not Installed
msgpack-python: 0.4.8
 mysql-python: Not Installed
    pycparser: Not Installed
     pycrypto: 2.6.1
 pycryptodome: 3.4.3
       pygit2: Not Installed
       Python: 2.7.5 (default, Nov  6 2016, 00:28:07)
 python-gnupg: Not Installed
       PyYAML: 3.11
        PyZMQ: 15.3.0
         RAET: Not Installed
        smmap: Not Installed
      timelib: Not Installed
      Tornado: 4.2.1
          ZMQ: 4.1.4

System Versions:
         dist: centos 7.3.1611 Core
       locale: UTF-8
      machine: x86_64
      release: 3.10.0-514.10.2.el7.x86_64
       system: Linux
      version: CentOS Linux 7.3.1611 Core

This is really critical, as any state.apply fails right now. One of the states we have is to use the latest pkg for salt-minion but 2017.7.0 breaks it all.

bartlaarhoven avatar Jul 19 '17 12:07 bartlaarhoven

Confirming I am also seeing this issue after updating to 2017.7.0 this evening.

OliverKellyATech avatar Jul 19 '17 13:07 OliverKellyATech

I'm seeing the same issue as well. Here is my version report if it's helpful:

Salt Version:
           Salt: 2017.7.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.6 (default, Oct 26 2016, 20:30:19)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-100-generic
         system: Linux
        version: Ubuntu 14.04 trusty

tannerwilliams avatar Jul 19 '17 13:07 tannerwilliams

What version is your master? This might be similar to https://github.com/saltstack/salt/issues/42283

As we normally don't support a master at a lower version this especially doesn't work this release as documented here

I cannnot replicate this behavior when my master and minion are both at verion 2017.7.0

Ch3LL avatar Jul 19 '17 13:07 Ch3LL

Your thoughts are good: my master is in 2016.11.6 and my minion in 2017.7.0 My bad, didn't read the hole release notes before testing. It works just fine with an up-to-date master.

Think this issue could now be closed. Thanks for the quick help!

tomlaredo avatar Jul 19 '17 13:07 tomlaredo

No problem :) Thanks for the quick reply!

Ch3LL avatar Jul 19 '17 13:07 Ch3LL