-
Notifications
You must be signed in to change notification settings - Fork 344
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
#996: AWS Fix KeyError exception when getting DNSName for load_balancer_id #1215
Conversation
@aliahmed-58 - thanks for the write-up and the PR. The tests are currently failing with
so you might need to update them. It definitely would be helpful to also include gateway types: can you please include a gateway type in the test data and write a test that verifies that it is loaded to the graph correctly? Write back if you need help with this. Please also sign the CLA. As a side note, we're currently working on #1024 to standardize AWS node IDs to use ARNs, and this will involve using our new data model which will make things cleaner and less error prone. Happy to share more here if you're interested too. |
@achantavy I have updated the tests to include the Also, the Yes I would be interested to look into https://github.com/lyft/cartography/issues/1024. Is there any communication channel where I can ask around (slack / discord etc) ? Thanks |
Yup!
On your local machine, make sure that you have done About Slack and other places to hang out, see https://github.com/lyft/cartography#community. We also have a community meeting coming up on 7/27 - please come if you can, would like to learn how you're using the tool. |
@achantavy I have written the test for type gateway load balancer. It works even when there's no I couldn't edit the original test method since it would take a lot of changes to test for another load balancer in PS. Thank you for the links |
Hi @aliahmed58 - let's actually pause work on this until...
I've created #1222 to track the problem you mentioned though. I'll write back if I need help on the refactors but at this point I think it's faster if I just power through some of these and then share the examples afterward. If you have cycles at that point to help let me know :) |
Fix: KeyError exception when getting DNSName for load_balancer_id
The type
gateway
Load Balancer V2 does not have the fieldDNSName
which was being used as id for theLoadBalancerV2
node during sync which resulted in KeyError if the sync loaded agateway
type load balancer.Solution
The solution is to use the
arn
as the id for LoadBalancerV2 nodes and setdnsname
property for the node only if it exists. If it returns None, then it won't be set in Neo4j.Changing the id from
dnsname
toarn
also requires to changecartography/intel/aws/ec2/network_interfaces.py
since it creates a relationship between(:LoadBalancerV2)-[:NETWORK_INTERFACE]->(:NetworkInterface)
which uses id (arn
instead ofdnsname
now) to query the LoadBalancerV2. Thearn
can be easily generated from the description string of network interface.The
arn
is of format:where the part
${Type}/${LoadBalancerName}/${LoadBalancerId}
can be found in the description of the network interface and can be retrieved using split on the description string if it initially matches the regex for load balancer v2.Sample description strings:
The regex matching was only looking for
net
andapp
type load balancers but addinggwy
makes it also find network interfaces for gateway load balancers and forms their relationships.This also fixes the currently unidentified problem that cartography did not make a relationship for
gateway
load balancers with their network interfaces since the regex never matchedgwy
.