saltstack / saltstack/salt

[BUG] boto_rds.subnet_group_present broken

Open
#61,555 0 comments 3 reactions 1 assignee View on GitHub

@krionbsd is already working on this.

Since Jan 31, 2022.

boto bug python3 Regression severity-high
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description

boto_rds.subnet_group_present no longer works on 3004 (it last worked for me on 3000.9 with Python 2.7)

Setup

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD

System boto packages:

python3-boto      2.44.0-1.1
python3-boto3     1.9.86-1
python3-botocore  1.12.103+repack-1

test_boto_subnet_group_present.sls:

test_subnet_group_creation:
  boto_rds.subnet_group_present:
    - region: us-east-2
    - name: test_subnet-group
    - description: test_subnet-group
    - subnet_names:
      - private-one_core_subnet
      - private-two_core_subnet

Steps to Reproduce the behavior

  1. (Authentication is not an issue, other boto states work fine)
  2. Apply test state:
    sudo salt-call state.apply test_boto_subnet_group_present
    
  3. Get error:
    local:
    ----------
              ID: test_subnet_group_creation
        Function: boto_rds.subnet_group_present
          Result: False
         Comment: An exception occurred in this state: Traceback (most recent call last):
                    File "/usr/lib/python3/dist-packages/salt/modules/boto_rds.py", line 219, in subnet_group_exists
                      rds = conn.describe_db_subnet_groups(DBSubnetGroupName=name)
                    File "/usr/lib/python3/dist-packages/botocore/client.py", line 357, in _api_call
                      return self._make_api_call(operation_name, kwargs)
                    File "/usr/lib/python3/dist-packages/botocore/client.py", line 661, in _make_api_call
                      raise error_class(parsed_response, operation_name)
                  botocore.errorfactory.DBSubnetGroupNotFoundFault: An error occurred (DBSubnetGroupNotFoundFault) when calling the DescribeDBSubnetGroups operation: DB Subnet group 'test_subnet-group' not found.
                  
                  During handling of the above exception, another exception occurred:
                  
                  Traceback (most recent call last):
                    File "/usr/lib/python3/dist-packages/salt/state.py", line 2180, in call
                      *cdata["args"], **cdata["kwargs"]
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
                      return self.loader.run(run_func, *args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
                      return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
                      return _func_or_method(*args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1249, in wrapper
                      return f(*args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/states/boto_rds.py", line 556, in subnet_group_present
                      name=name, tags=tags, region=region, key=key, keyid=keyid, profile=profile
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
                      return self.loader.run(run_func, *args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
                      return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
                      return _func_or_method(*args, **kwargs)
                    File "/usr/lib/python3/dist-packages/salt/modules/boto_rds.py", line 222, in subnet_group_exists
                      if "DBSubnetGroupNotFoundFault" in e.message:
                  AttributeError: 'DBSubnetGroupNotFoundFault' object has no attribute 'message'
         Started: 20:06:01.866093
        Duration: 234.686 ms
         Changes:
    

Expected behavior

salt state should work as documented and as it did previously

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3004
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: 2.0.5
     gitpython: 2.1.11
        Jinja2: 2.10
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.7.3 (default, Jan 22 2021, 20:04:44)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 17.1.2
         smmap: 2.0.5
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.1
 
System Versions:
          dist: debian 10 buster
        locale: UTF-8
       machine: x86_64
       release: 4.19.0-18-amd64
        system: Linux
       version: Debian GNU/Linux 10 buster

Additional context

Based on https://github.com/fugue/credstash/issues/224#issuecomment-548553323, it seems like this is a Python 2 => Python 3 issue.

Potential solution:

--- boto_rds.py.76e5088	2022-01-31 20:34:20.477882216 +0000
+++ boto_rds.py.NEW	2022-01-31 20:30:32.830970932 +0000
@@ -219,7 +219,7 @@
         rds = conn.describe_db_subnet_groups(DBSubnetGroupName=name)
         return {"exists": bool(rds)}
     except ClientError as e:
-        if "DBSubnetGroupNotFoundFault" in e.message:
+        if "DBSubnetGroupNotFoundFault" in str(e):
             return {"exists": False}
         else:
             return {"error": __utils__["boto3.get_error"](e)}

This solution works for me, but maybe something like what parameter_group_exists() has would be better.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.