Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boto_asg.present can no longer return a proper value #64015

Open
morfie78 opened this issue Apr 3, 2023 · 4 comments · May be fixed by #64080
Open

boto_asg.present can no longer return a proper value #64015

morfie78 opened this issue Apr 3, 2023 · 4 comments · May be fixed by #64080
Labels
boto AWS wrapper modules Bug broken, incorrect, or confusing behavior needs-triage

Comments

@morfie78
Copy link

morfie78 commented Apr 3, 2023

Description of Issue

when using boto_asg.present, it now results in:

Traceback (most recent call last):
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/state.py", line 2276, in call
    ret = self.states[cdata["full"]](
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 1276, in wrapper
    return f(*args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/states/boto_asg.py", line 534, in present
    asg = __salt__["boto_asg.get_config"](name, region, key, keyid, profile)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/home/user/venv/infra/lib/python3.10/site-packages/salt/modules/boto_asg.py", line 187, in get_config
    ret[attr] = getattr(asg, attr).split(",")
AttributeError: 'NoneType' object has no attribute 'split'

Retrieving vpc_zone_identifiers result in None instead of array.
Salt uses the boto.ec2.autoscale library to get an asg object, then retrieve a list of vpc_zone_identifiers. Now, all of a sudden, this has stopped working and returns "None":

Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from boto.ec2.autoscale import *
>>> c = boto.ec2.autoscale.connect_to_region('us-east-1')
>>> asg = c.get_all_groups(names=['xxxxxxxxxxxxxxxxxxxxxxxxxx'])[0]
>>> print(asg.vpc_zone_identifier)
None

Boto3 still does this successfully:

>>> import boto3
>>> 
>>> asg_name = 'xxxxxxxxxxxx'
>>> client = boto3.client('autoscaling')
>>> asg_details = client.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name])
>>> vpc_zone_identifier = asg_details['AutoScalingGroups'][0]['VPCZoneIdentifier']
>>> print(vpc_zone_identifier)
subnet-xxxxxxxxxxxx,subnet-yyyyyyyyyyyy

The automation we use depends on this, and this was working until the end of last week.

This may have something to do with AWS changing things on their end: https://aws.amazon.com/about-aws/whats-new/2023/03/general-availability-amazon-vpc-lattice/

Setup

Provided in the Description

Steps to Reproduce Issue

# ASG Settings.
Ensure xxxxxxxxxxxxxxxxxxxx asg exists:
  boto_asg.present:
    - name: zzzzzzzzzzzzzzzzzzzzz
    - load_balancers:
      - xxxxxxxxxxxxxxxxxxxxxxxxx
      - yyyyyyyyyyyyyyyyyyyyyyyy
    - launch_config_name: zzzzzzzzzzzzzzzzzzzzzz
    - launch_config:
      - image_id: ami-xxxxxxxxxxxxxxxxxxxx
      - key_name: aaaaaaaaa
      - security_groups:
        - sssssssssssssssggggggggggggggg
      - instance_profile_name: zzzzzzzzzzzzzzzzzzzzzzzzz
      - instance_type: m5.xlarge
      - block_device_mappings:
        - "/dev/sda1":
            size: 500
            volume_type: gp3
            delete_on_termination: true
      - associate_public_ip_address: true
      - instance_monitoring: true
    - vpc_zone_identifier: ['subnet-xxxxxxxxxxxxxxx','subnet-yyyyyyyyyyyyyy' ]
    - availability_zones: ['us-east-1b','us-east-1c']
    - min_size: 1
    - max_size: 1
    - health_check_type: EC2
    - health_check_period: 900
    - termination_policies:
       - OldestInstance
       - OldestLaunchConfiguration
    - tags:
      - key: 'Name'
        value: 'cccccccccccccccccccccc'
    - profile: infra_profile

Versions Report

$ salt --versions-report
Salt Version:
          Salt: 3005.1+7.gfe67de4b7f
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.5
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 3.10.1
  pycryptodome: 3.17
        pygit2: Not Installed
        Python: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.3
 
System Versions:
          dist: ubuntu 22.04 Jammy Jellyfish
        locale: utf-8
       machine: x86_64
       release: 5.19.0-38-generic
        system: Linux
       version: Ubuntu 22.04 Jammy Jellyfish
@welcome
Copy link

welcome bot commented Apr 3, 2023

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!

@abrom
Copy link

abrom commented Apr 6, 2023

We're seeing the same thing. We've also noticed that the boto library is also returning no tags, and calls to describe_auto_scaling_groups can return "phantom" ASGs with no properties at all. We're working through patching modules/boto_asg.py to use boto3 now.. if that all works we'll look to submit a PR 😄

@peycho
Copy link

peycho commented Apr 6, 2023

AWS support said:

On investigation, the python boto SDK has been deprecated, with the last released version 5 years ago. As such, it is no longer supported, and there will be no further changes or development to maintain/support this. However, the source code is available, and you are welcome to continue to use and modify this for your own use as necessary.

@OrangeDog OrangeDog added Bug broken, incorrect, or confusing behavior needs-triage boto AWS wrapper modules labels Apr 6, 2023
binocvlar added a commit to binocvlar/salt that referenced this issue Apr 14, 2023
Replace all calls to `get_all_groups` with a boto3 equivalent
implementation. This change is being made to address the breakage
highlighted in issue saltstack#64015.

Note that this port doesn't touch any of the other uses of boto which
still appear to be functioning correctly. These should probably be
tackled as a matter of priority though.
binocvlar added a commit to binocvlar/salt that referenced this issue Apr 14, 2023
Replace all calls to `get_all_groups` with a boto3 equivalent
implementation. This change is being made to address the breakage
highlighted in issue saltstack#64015.

Note that this port doesn't touch any of the other uses of boto which
still appear to be functioning correctly. These should probably be
tackled as a matter of priority though.
@binocvlar binocvlar linked a pull request Apr 14, 2023 that will close this issue
3 tasks
@binocvlar
Copy link
Contributor

binocvlar commented Apr 14, 2023

I've raised a PR which seeks to circumvent this recent behaviour change within boto: #64080 - specifically, the call to get_all_groups within get_config has been replaced using the boto3 equivalent. Key names in the return value from get_config have been retained in order to preserve the original behaviour.

We've tested this within our stack, and it seems to be working as expected.

Note that I haven't written a new test suite (presently, I don't think there is one for boto_asg.py), and don't have time to do so.
If this PR should be targeting another branch instead, please let me know.

s0undt3ch pushed a commit to binocvlar/salt that referenced this issue Aug 14, 2023
Replace all calls to `get_all_groups` with a boto3 equivalent
implementation. This change is being made to address the breakage
highlighted in issue saltstack#64015.

Note that this port doesn't touch any of the other uses of boto which
still appear to be functioning correctly. These should probably be
tackled as a matter of priority though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boto AWS wrapper modules Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants