You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/08/07 00:15:33 UTC

[GitHub] [trafficcontrol] rob05c commented on a change in pull request #4916: Multi interface health

rob05c commented on a change in pull request #4916:
URL: https://github.com/apache/trafficcontrol/pull/4916#discussion_r466751810



##########
File path: lib/go-tc/servers.go
##########
@@ -97,6 +99,30 @@ type ServerInterfaceInfo struct {
 	Name         string            `json:"name" db:"name"`
 }
 
+// GetDefaultAddress returns the IPv4 and IPv6 service addresses of the interface.
+func (i *ServerInterfaceInfo) GetDefaultAddress() (string, string) {
+	var ipv4 string
+	var ipv6 string
+	for _, ip := range i.IPAddresses {
+		if ip.ServiceAddress {
+			address, _, err := net.ParseCIDR(ip.Address)
+			if err != nil || address == nil {
+				continue

Review comment:
       +1 - libraries should return errors, never log. If this really needs to return a warning, the function can be documented to return a "non-fatal error", or "warnings string array" or something. But that doesn't seem valuable enough to me to warrant the awkwardness. I would vote documenting the behavior in the function doc, though, e.g. "Addresses which aren't valid CIDR are ignored." 
   
   But +1 to everything @ocket8888 said.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org