Salt: Exception raised when processing __virtual__ function for salt.loaded.int.module.boto_elbv2. Module will not be loaded

Created on 12 Oct 2017  路  7Comments  路  Source: saltstack/salt

Description of Issue/Question

In salt minion logs I see:

2017-10-12 12:26:16,832 [salt.utils.lazy  ][DEBUG   ][4571] LazyLoaded boto3.assign_funcs
2017-10-12 12:26:16,832 [salt.loader      ][DEBUG   ][4571] Error loading module.boto_elasticsearch_domain: __init__ failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1464, in _load_module
    module_init(self.opts)
  File "/usr/lib/python2.7/dist-packages/salt/modules/boto_elasticsearch_domain.py", line 135, in __init__
    __utils__['boto3.assign_funcs'](__name__, 'es')
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1113, in __getitem__
    func = super(LazyLoader, self).__getitem__(item)
  File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 98, in __getitem__
    return self._dict[key]
KeyError: 'boto3.assign_funcs'
2017-10-12 12:26:16,833 [salt.utils.lazy  ][DEBUG   ][4571] LazyLoaded boto3.assign_funcs
2017-10-12 12:26:16,833 [salt.loader      ][ERROR   ][4571] Exception raised when processing __virtual__ function for salt.loaded.int.module.boto_elbv2. Module will not be loaded: 'boto3.assign_funcs'
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1672, in process_virtual
    virtual = getattr(mod, virtual_func)()
  File "/usr/lib/python2.7/dist-packages/salt/modules/boto_elbv2.py", line 71, in __virtual__
    __utils__['boto3.assign_funcs'](__name__, 'elbv2')
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1113, in __getitem__
    func = super(LazyLoader, self).__getitem__(item)
  File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 98, in __getitem__
    return self._dict[key]
KeyError: 'boto3.assign_funcs'
2017-10-12 12:26:16,833 [salt.loader      ][WARNING ][4571] salt.loaded.int.module.boto_elbv2.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'boto_elbv2', please fix this.

Versions Report

# salt --versions-report
Salt Version:
           Salt: 2017.7.1

Dependency Versions:
           cffi: 1.9.1
       cherrypy: 3.2.2
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.3
      gitpython: 0.3.4
          ioflo: Not Installed
         Jinja2: 2.8
        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: 2.17
       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.12
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4

System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-115-generic
         system: Linux
        version: Ubuntu 14.04 trusty
Bug P2 fixed-pending-your-verification severity-medium stale

Most helpful comment

These problems are caused because Salt distributes this module:

salt/utils/boto3.py

When you import boto3, there's a chance that it actually imports Salt's own module with that name rather than the actual boto3 library (depending on how sys.path is setup).

If you actually remove botocore from your machine (e.g. on CentOS yum remove python2-botocore), these warnings will go away. This is because part of Salt's validation that boto3 is installed includes a validation that botocore is installed. Thus if botocore is missing, that validation fails, and Salt doesn't even try to do anything with boto3.

I think this can be solved by using absolute imports.

All 7 comments

Could be duplication of #42311 but I'm having this error with state.highstate

Got the same error

vagrant@localsandbox:~$ sudo salt-call --state-verbose=false state.apply common.email
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.boto_elbv2. Module will not be loaded: 'boto3.assign_funcs'
[WARNING ] salt.loaded.int.module.boto_elbv2.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'boto_elbv2', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.boto_kinesis. Module will not be loaded: 'boto3.assign_funcs'
[WARNING ] salt.loaded.int.module.boto_kinesis.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'boto_kinesis', please fix this.
local:

Summary for local
------------
Succeeded: 5
Failed:    0
------------
Total states run:     5
Total run time: 104.000 ms

Tracked it to the inclusion of service.running , none of the above if commented out.

Postfix service running:
  service.running:
    - name: postfix
    - enable: True

vagrant@localsandbox:~$ salt-call --versions-report
Salt Version:
Salt: 2017.7.2

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: 1.10.6
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 0.9.1
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.6 (default, Nov 23 2017, 15:49:48)
python-gnupg: 0.4.1
PyYAML: 3.10
PyZMQ: 14.0.1
RAET: Not Installed
smmap: Not Installed
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-135-generic
system: Linux
version: Ubuntu 14.04 trusty

vagrant@localsandbox:~$

Seeing the same in an Amazon linux instance:

# salt-call --versions-report
Salt Version:
           Salt: 2017.7.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov  2 2017, 19:20:38)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist:   
         locale: UTF-8
        machine: x86_64
        release: 4.9.75-25.55.amzn1.x86_64
         system: Linux
        version: Not Installed

These problems are caused because Salt distributes this module:

salt/utils/boto3.py

When you import boto3, there's a chance that it actually imports Salt's own module with that name rather than the actual boto3 library (depending on how sys.path is setup).

If you actually remove botocore from your machine (e.g. on CentOS yum remove python2-botocore), these warnings will go away. This is because part of Salt's validation that boto3 is installed includes a validation that botocore is installed. Thus if botocore is missing, that validation fails, and Salt doesn't even try to do anything with boto3.

I think this can be solved by using absolute imports.

But we need boto3 on this server for other purposes, i.e. for managing AWS. So we can't simply remove it.

@DenisBY I'm not suggesting you solve the warnings issue by removing it, I'm just noting one side effect of Salt's detection logic. The real solution requires Salt patch the boto3 Salt module to use absolute imports.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lhost picture lhost  路  3Comments

saurabhnemade picture saurabhnemade  路  3Comments

golmaal picture golmaal  路  3Comments

icycle77 picture icycle77  路  3Comments

nixjdm picture nixjdm  路  3Comments