This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 6ba2914  Fixed TM to report ONLINE caches as available (#5776)
6ba2914 is described below

commit 6ba291470cc18ed86b79921ce28a41af594b3770
Author: mattjackson220 <[email protected]>
AuthorDate: Thu Apr 22 10:17:20 2021 -0600

    Fixed TM to report ONLINE caches as available (#5776)
---
 CHANGELOG.md                             |  1 +
 traffic_monitor/datareq/cachestate.go    | 15 +++++++++++++++
 traffic_monitor/manager/monitorconfig.go |  2 +-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bf4f6c..95ce6db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#5724](https://github.com/apache/trafficcontrol/issues/5724) - Set XMPPID 
to hostname if the server had none, don't error on server update when XMPPID is 
empty
 - [#5744](https://github.com/apache/trafficcontrol/issues/5744) - Sort TM 
Delivery Service States page by DS name
 - Fixed server creation through legacy API versions to default `monitor` to 
`true`.
+- Fixed Traffic Monitor to report `ONLINE` caches as available.
 
 ### Changed
 - Updated the Traffic Ops Python client to 3.0
diff --git a/traffic_monitor/datareq/cachestate.go 
b/traffic_monitor/datareq/cachestate.go
index 4597e2e..2482744 100644
--- a/traffic_monitor/datareq/cachestate.go
+++ b/traffic_monitor/datareq/cachestate.go
@@ -38,6 +38,9 @@ import (
 // the polled interface data.
 const NotFoundStatus = "unavailable - interface not found"
 
+// OnlineStatus is the status value of all interfaces that are associated with 
an ONLINE server.
+const OnlineStatus = "available - server ONLINE"
+
 // CacheStatus contains summary stat data about the given cache.
 type CacheStatus struct {
        Type        *string  `json:"type,omitempty"`
@@ -183,6 +186,11 @@ func createCacheStatuses(
                                }
                        }
 
+                       if serverInfo.ServerStatus == 
tc.CacheStatusOnline.String() {
+                               infStatus.Status = OnlineStatus
+                               infStatus.Available = true
+                       }
+
                        interfaceStatuses[interfaceName] = infStatus
                }
 
@@ -235,6 +243,13 @@ func createCacheStatuses(
                        log.Infof("Error getting cache %v health span: %v\n", 
cacheName, err)
                }
 
+               if serverInfo.ServerStatus == tc.CacheStatusOnline.String() {
+                       cacheStatus.Why = "ONLINE - available"
+                       cacheStatus.Available.IPv4 = serverInfo.IPv4() != ""
+                       cacheStatus.Available.IPv6 = serverInfo.IPv6() != ""
+                       cacheStatus.ProcessedAvailable = 
cacheStatus.Available.IPv4 || cacheStatus.Available.IPv6
+               }
+
                statii[cacheName] = CacheStatus{
                        Type:                   &cacheTypeStr,
                        LoadAverage:            &loadAverage,
diff --git a/traffic_monitor/manager/monitorconfig.go 
b/traffic_monitor/manager/monitorconfig.go
index 4f44042..719720c 100644
--- a/traffic_monitor/manager/monitorconfig.go
+++ b/traffic_monitor/manager/monitorconfig.go
@@ -240,7 +240,7 @@ func monitorConfigListen(
 
                        srvStatus := tc.CacheStatusFromString(srv.ServerStatus)
                        if srvStatus == tc.CacheStatusOnline {
-                               localStates.AddCache(cacheName, 
tc.IsAvailable{IsAvailable: true})
+                               localStates.AddCache(cacheName, 
tc.IsAvailable{IsAvailable: true, Ipv6Available: srv.IPv6() != "", 
Ipv4Available: srv.IPv4() != ""})
                                continue
                        }
                        if srvStatus == tc.CacheStatusOffline {

Reply via email to