zrhoffman commented on code in PR #7302:
URL: https://github.com/apache/trafficcontrol/pull/7302#discussion_r1089231305


##########
traffic_monitor/cache/astats.go:
##########
@@ -116,8 +117,23 @@ func astatsParse(cacheName string, rdr io.Reader, pollCTX 
interface{}) (Statisti
                astats.Ats["system.proc.loadavg"] = astats.System.ProcLoadavg
                astats.Ats["system.proc.net.dev"] = astats.System.ProcNetDev
 
+               via := ctx.HTTPHeader.Get("Via")

Review Comment:
   > Please add the `Via` header to `rfc` package and include the RFC for it:
   > 
   > 
https://github.com/apache/trafficcontrol/blob/0321d207699d390fdfa6067616ef955d084628ff/lib/go-rfc/http.go#L31-L34
   
   Still needs to be added. Let me know if you have any questions about this



##########
traffic_monitor/datareq/crstate.go:
##########
@@ -84,10 +88,55 @@ func filterDirectlyPolledCaches(crstates tc.CRStates) 
tc.CRStates {
        return filtered
 }
 
-func srvTRStateSelf(localStates peer.CRStatesThreadsafe, directlyPolledOnly 
bool) ([]byte, error) {
+func srvTRStateSelf(localStates peer.CRStatesThreadsafe, directlyPolledOnly 
bool, toData todata.TODataThreadsafe) ([]byte, error) {
        if !directlyPolledOnly {
-               return tc.CRStatesMarshall(localStates.Get())
+               localStatesC := updateStatusAnycast(localStates, toData)
+               return tc.CRStatesMarshall(localStatesC)
        }
-       unfiltered := localStates.Get()
+       unfiltered := updateStatusAnycast(localStates, toData)
        return tc.CRStatesMarshall(filterDirectlyPolledCaches(unfiltered))
 }
+
+func updateStatusAnycast(localStates peer.CRStatesThreadsafe, toData 
todata.TODataThreadsafe) tc.CRStates {
+       localStatesC := localStates.Get()
+       toDataC := toData.Get()
+
+       for cache, _ := range localStatesC.Caches {
+               if _, ok := toDataC.ServerPartners[cache]; ok {
+                       // all server partners must be available if they are in 
reported state
+                       allAvailableV4 := true
+                       allAvailableV6 := true
+                       allIsAvailable := true
+                       for partner, _ := range toDataC.ServerPartners[cache] {
+                               if partnerState, ok := 
localStatesC.Caches[partner]; ok {
+                                       // a partner host is reported but is 
marked down for too high traffic or load
+                                       // this host also needs to be marked 
down to divert all traffic for their
+                                       // common anycast ip
+                                       if 
strings.Contains(partnerState.Status, "REPORTED") &&
+                                               
strings.Contains(partnerState.Status, "too high") {
+                                               if !partnerState.Ipv4Available {
+                                                       allAvailableV4 = false
+                                               }
+                                               if !partnerState.Ipv6Available {
+                                                       allAvailableV6 = false
+                                               }
+                                               if !partnerState.IsAvailable {
+                                                       allIsAvailable = false
+                                               }

Review Comment:
   > We can break here if `partnerState.Ipv4Available`, 
`partnerState.Ipv6Available`, and `partnerState.IsAvailable` are all `false`, 
right?
   
   Any reason not to do this?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to