m-lab / traceroute-caller

A sidecar service which runs traceroute after a connection closes
Apache License 2.0
18 stars 5 forks source link

Add load balancer IPs to "localIPs" #167

Closed nkinkade closed 1 month ago

nkinkade commented 1 month ago

It was recently discovered that VMs that are part of managed instance groups (i.e., load balanced) are not producing hopannotation2 or scamper1 data from the traceroute-caller container. This is because the socket information provided by tcp-info specifies the load balancer IP address, and traceroute-caller was unable to identify the address as "local", so would refuse to run traces, exiting with an error.

This PR adds a new loadbalanerIPs() function which will extract loadbalancer IP addresses, if any, from machine metadata (/var/local/metadata) mounted into the container at /metadata. It adds any loadbalancer IPs to the slice handler.LocalIPs so that it can associate LB IP addresses as local, allowing it to determine the proper destination for a traceroute.

I made one other small change, which was to change the type of Handler.LocalIPs from []*net.IP to []net.IP. I found the slice-of-pointers hard to work with, and unless there was some reason that was being done that I'm not aware of, it is apparently generally bad form in Go to create slices of pointers, since slices are passed around by reference by default anyway.

I also took the opportunity to update Go to v1.21 (maybe I should have gone to v1.22?)


This change is Reviewable