-
Notifications
You must be signed in to change notification settings - Fork 138
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
CBG-1424 - Show network interface stats when configured API listen adresses use hostnames instead of IPs #5001
Conversation
…g network interface addresses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach looks fine - question about a multiple address/multiple interface scenario.
for _, ifaceCIDRAddr := range ifaceAddresses { | ||
|
||
ipAddr, _, err := net.ParseCIDR(ifaceCIDRAddr.String()) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if ipAddr.String() == host { | ||
if _, ok := hosts[ipAddr.String()]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the scenario where a host has multiple addresses, is it possible for those addresses to assigned to different interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's possible, but the interface actually being used for the REST API depends what was first in the resolved list of addresses at the time of net.Listen()
which does not support multiple addresses.
I think that means that as long as LookupHost
resolves in the same order as net.Listen
, you'll get correct results - but if that does not happen, you'll see stats for another interface. I don't know how likely or unlikely this is.
There's a "correct" implementation that resolves an address before starting up the HTTP servers, so we know exactly what to look for in this stat code, but I'm not sure it's worth that to cover this specific case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - thanks.
…ured API listen adresses use hostnames instead of IPs (#5001) * Resolve hostnames in discoverInterfaceName when searching for matching network interface addresses * Simplify networkInterfaceStatsForHostnamePort
…n configured API listen adresses use hostnames instead of IPs (#5001) (#5268) Co-authored-by: Ben Brooks <[email protected]>
discoverInterfaceName
, prior to searching for a matching network interface.networkInterfaceStatsForHostnamePort
:allInterfaces
bool in favour of singleperNic
localhost
->127.0.0.1
(let the resolver deal with that, along with others likelocalhost4
,localhost6
, and proper hostnames likeadmin.sgw.example.com
)Manual testing:
admin_net_bytes_recv
stat and no warning in logs.Before:
After: