boto_vpc.vpc_peering_connection_present state function is broken
Open
Nobody has claimed this yet.
boto
bug
severity-medium
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue/Question
When using the boto_vpc.vpc_peering_connection_present state function to create a peering connection, the peering connection is requested, but not accepted.
Looking at the code, it seems like there are a few problems:
- The request is only made after attempting to accept, which means you would have to run the state twice for full effect.
- The if statements before the accept will always evaluate to true if the state made the request in a previous run, meaning you'll always hit the "already requested - pending acceptance" return.
- The only way for the accept to actually happen is if the pending request came from a VPC other than the one you're providing in the
requester_vpc_name/requester_vpc_idarguments!?
Setup
#!jinja|yaml
{%- set profile = salt['pillar.get']('aws_profile') %}
aws_peering_test:
boto_vpc.vpc_peering_connection_present:
- conn_name: test1_to_test2
- requester_vpc_name: test1
- peer_vpc_name: test2
- profile: {{ profile | tojson }}
Steps to Reproduce Issue
[root@dev-master salt]# salt dev-master state.sls aws.vpc_test
dev-master:
----------
ID: aws_peering_test
Function: boto_vpc.vpc_peering_connection_present
Result: True
Comment: Boto VPC peering state
Started: 01:02:13.418258
Duration: 1147.476 ms
Changes:
----------
new:
VPC peering pcx-096fb1b3d82182818 requested. With name test1_to_test2.
old:
Summary for dev-master
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 1.147 s
[root@dev-master salt]# salt dev-master state.sls aws.vpc_test
dev-master:
----------
ID: aws_peering_test
Function: boto_vpc.vpc_peering_connection_present
Result: True
Comment: VPC peering test1_to_test2 already requested - pending acceptance by test2
Started: 01:02:20.760447
Duration: 730.102 ms
Changes:
Summary for dev-master
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 730.102 ms
Versions Report
Salt Version:
Salt: 2019.2.0
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.8.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
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.13 (default, Feb 20 2019, 09:59:36)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: centos 6.10 Final
locale: UTF-8
machine: x86_64
release: 2.6.32-754.10.1.el6.x86_64
system: Linux
version: CentOS 6.10 Final
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the boto_vpc.vpc_peering_connection_present state function and reproduce the setup by running the provided state twice. Inspect the request and acceptance ordering and the conditions around pending requests. Done means the connection can be requested and accepted as intended without requiring a second state run, while repeated runs remain idempotent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100