zrhoffman commented on code in PR #7302: URL: https://github.com/apache/trafficcontrol/pull/7302#discussion_r1152185665
########## docs/source/admin/traffic_monitor.rst: ########## @@ -79,6 +79,7 @@ traffic_monitor.cfg - ``health.polling.interval`` - ``peers.polling.interval`` - ``heartbeat.polling.interval`` +- ``tm.sameipservers.control`` - When set to true, performs an AND operation on the availability statuses of servers with same ip. Any unavailable server(s) with same ip as other server(s) will cause the other server(s) to be set to unavailable. Review Comment: `tm.sameipservers.control` is a little ambiguous how about `tm.sameipservers.enabled`? We use `.enabled` for parameters elsewhere in the project. ########## traffic_monitor/datareq/crstate.go: ########## @@ -84,10 +82,63 @@ func filterDirectlyPolledCaches(crstates tc.CRStates) tc.CRStates { return filtered } -func srvTRStateSelf(localStates peer.CRStatesThreadsafe, directlyPolledOnly bool) ([]byte, error) { +func srvTRStateData(localStates peer.CRStatesThreadsafe, directlyPolledOnly bool, toData todata.TODataThreadsafe, monitorConfig threadsafe.TrafficMonitorConfigMap) ([]byte, error) { + if val, ok := monitorConfig.Get().Config["tm.sameipservers.control"]; ok && val.(string) == "true" { + localStatesC := updateStatusSameIpServers(localStates, toData) + if !directlyPolledOnly { + return tc.CRStatesMarshall(localStatesC) + } + return tc.CRStatesMarshall(filterDirectlyPolledCaches(localStatesC)) + } if !directlyPolledOnly { return tc.CRStatesMarshall(localStates.Get()) } - unfiltered := localStates.Get() - return tc.CRStatesMarshall(filterDirectlyPolledCaches(unfiltered)) + return tc.CRStatesMarshall(filterDirectlyPolledCaches(localStates.Get())) Review Comment: How about something like this to reduce code duplication? ```go var unfiltered tc.CRStates if val, ok := monitorConfig.Get().Config["tm.sameipservers.control"]; ok && val.(string) == "true" { unfiltered = updateStatusSameIpServers(localStates, toData) } else { unfiltered = localStates.Get() } if !directlyPolledOnly { return tc.CRStatesMarshall(unfiltered) } return tc.CRStatesMarshall(unfiltered) ``` -- 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. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org