saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.21k stars 5.48k forks source link

[BUG] boto3mod requires boto #62672

Closed bdrx312 closed 1 year ago

bdrx312 commented 2 years ago

Description

The boto3mod utils module imports the old boto module (https://github.com/saltstack/salt/blob/998cb0f951f32f79917109f95edcb5d3cee83cec/salt/utils/boto3mod.py#L41) and not just boto3 and botocore modules. This therefore requires boto (not just boto3) to be installed to use the boto3_ specific execution modules like boto3_sns (https://github.com/saltstack/salt/blob/master/salt/modules/boto3_sns.py), boto3_route53 (https://github.com/saltstack/salt/blob/master/salt/modules/boto3_route53.py), boto3_elasticsearch (https://github.com/saltstack/salt/blob/master/salt/modules/boto3_elasticsearch.py), and boto3_elasticache (https://github.com/saltstack/salt/blob/master/salt/modules/boto3_elasticache.py) since they use __utils__["boto3.assign_funcs"]

Setup

Steps to Reproduce the behavior

$ /usr/bin/pip3 freeze
boto3==1.17.98
botocore==1.20.98
chardet==3.0.4
contextvars==2.4
distro==1.2.0
idna==2.10
immutables==0.14
Jinja2==2.11.1
jmespath==0.10.0
M2Crypto==0.35.2
MarkupSafe==0.23
msgpack==0.6.2
psutil==5.6.7
pycurl==7.43.0
PySocks==1.6.8
python-dateutil==2.8.1
PyYAML==3.13
pyzmq==17.0.0
requests==2.14.2
rpm==4.11.3
s3transfer==0.4.2
salt==3004.1
six==1.14.0
urllib3==1.25.6

salt-call --local -l debug boto3_elasticsearch.describe_elasticsearch_domains

[DEBUG   ] Error loading module.boto3_elasticsearch: __init__ failed
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.y", line 883, in _load_module
    self.run(module_init, self.opts)
...
 File "/usr/lib/python3.6/site-packges/salt/modules/boto3_elasticsearch.py", line 94, in __init__
    __utils__["boto3.assign_funcs"](__name__, "es")
...
  File "/usr/lib/python3.6/site-packages/salt/utils/lazy.py, line 105, in __getitem__
    raise KeyError(key)
KeyError: 'boto3.assign_funcs'
[DEBUG   ] Could not LazyLoad boto3.assign_funcs: 'boto3.assign_funcs' is not available.
'boto3_elasticsearch' __virtual__ returned False: __init__ failed

Expected behavior

boto3_elasticsearch __virtual__ should return True since only boto3 should be required and not boto There should not be a KeyError calling boto3.assign_funcs

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ```yaml Salt Version: Salt: 3004.1 ```
welcome[bot] commented 2 years ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

bdrx312 commented 3 months ago

The import boto was removed but the boto library still has to be installed because of https://github.com/saltstack/salt/blob/3e60827193b40e9ec6639ef0205437c47dc0e550/salt/utils/boto3mod.py#L66

has_boto = salt.utils.versions.check_boto_reqs()

This needs to be changed to

has_boto = salt.utils.versions.check_boto_reqs(check_boto=False)