You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by sh...@apache.org on 2021/10/22 20:46:46 UTC
[trafficcontrol] branch master updated: Bugfix/5373 tm log
inconsistency (#6292)
This is an automated email from the ASF dual-hosted git repository.
shamrick 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 23408ab Bugfix/5373 tm log inconsistency (#6292)
23408ab is described below
commit 23408ab66f4565e86c2c8ffb86e9a7cfd5b8665e
Author: Taylor Clayton Frey <ta...@gmail.com>
AuthorDate: Fri Oct 22 14:46:38 2021 -0600
Bugfix/5373 tm log inconsistency (#6292)
* Removed duplicate event message.
Clarify event message to account for all availability scenarios.
Minor formatting for readability.
Add const for consistency and clarity
* Add changelog entry
Co-authored-by: Taylor Frey <ta...@comcast.com>
---
CHANGELOG.md | 1 +
traffic_monitor/ds/stat.go | 36 +++++++-------------------------
traffic_monitor/health/event.go | 4 ++++
traffic_monitor/manager/peer.go | 9 +++++++-
traffic_monitor/manager/statecombiner.go | 11 +++++++++-
5 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 095a769..27c2067 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6259](https://github.com/apache/trafficcontrol/issues/6259) - Traffic Portal No Longer Allows Spaces in Server Object "Router Port Name"
- [#6175](https://github.com/apache/trafficcontrol/issues/6175) - POST request to /api/4.0/phys_locations accepts mismatch values for regionName.
- [#6283](https://github.com/apache/trafficcontrol/issues/6283) - The Traffic Ops Postinstall script will work in CentOS 7, even if Python 3 is installed
+- [#5373](https://github.com/apache/trafficcontrol/issues/5373) - Traffic Monitor logs not consistent
### Changed
- Updated `t3c` to request less unnecessary deliveryservice-server assignment and invalidation jobs data via new query params supported by Traffic Ops
diff --git a/traffic_monitor/ds/stat.go b/traffic_monitor/ds/stat.go
index 56c8859..95f3b68 100644
--- a/traffic_monitor/ds/stat.go
+++ b/traffic_monitor/ds/stat.go
@@ -105,30 +105,6 @@ func addAvailableData(dsStats *dsdata.Stats, crStates tc.CRStates, serverCachegr
}
}
- for dsName, stat := range dsStats.DeliveryService {
- lastStat, lastStatExists := lastStats.DeliveryServices[dsName]
- if !lastStatExists {
- continue
- }
-
- getEvent := func(desc string) health.Event {
- // TODO sync.Pool?
- return health.Event{
- Time: health.Time(time.Now()),
- Description: desc,
- Name: dsName.String(),
- Hostname: dsName.String(),
- Type: "Delivery Service",
- Available: stat.CommonStats.IsAvailable.Value,
- }
- }
- if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true {
- events.Add(getEvent("no available caches"))
- } else if stat.CommonStats.IsAvailable.Value == true && lastStat.Available == false {
- events.Add(getEvent("available caches"))
- }
- }
-
// TODO move to its own func?
for dsName := range crStates.DeliveryService {
stat, ok := dsStats.DeliveryService[dsName]
@@ -325,14 +301,18 @@ func addDSPerSecStats(lastStats *dsdata.LastStats, dsStats *dsdata.Stats, dsName
Description: desc,
Name: dsName.String(),
Hostname: dsName.String(),
- Type: "DELIVERYSERVICE",
+ Type: health.DeliveryServiceEventType,
Available: stat.CommonStats.IsAvailable.Value,
}
}
- if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true && dsErr != nil {
- events.Add(getEvent(dsErr.Error())) // TODO change events.Add to not allocate new memory, after the limit is reached.
+ if stat.CommonStats.IsAvailable.Value == false && lastStat.Available == true {
+ eventDesc := "Unavailable"
+ if dsErr != nil {
+ eventDesc = eventDesc + " err: " + dsErr.Error()
+ }
+ events.Add(getEvent(eventDesc)) // TODO change events.Add to not allocate new memory, after the limit is reached.
} else if stat.CommonStats.IsAvailable.Value == true && lastStat.Available == false {
- events.Add(getEvent("REPORTED - available"))
+ events.Add(getEvent("Available caches"))
}
lastStat.Available = stat.CommonStats.IsAvailable.Value
diff --git a/traffic_monitor/health/event.go b/traffic_monitor/health/event.go
index 4afec86..7aa27bf 100644
--- a/traffic_monitor/health/event.go
+++ b/traffic_monitor/health/event.go
@@ -29,6 +29,10 @@ import (
"github.com/apache/trafficcontrol/lib/go-log"
)
+const (
+ DeliveryServiceEventType = "DELIVERYSERVICE"
+)
+
type Time time.Time
func (t Time) MarshalJSON() ([]byte, error) {
diff --git a/traffic_monitor/manager/peer.go b/traffic_monitor/manager/peer.go
index e733272..9c384cc 100644
--- a/traffic_monitor/manager/peer.go
+++ b/traffic_monitor/manager/peer.go
@@ -52,6 +52,13 @@ func comparePeerState(events health.ThreadsafeEvents, result peer.Result, peerSt
description = "Peer is unreachable"
}
- events.Add(health.Event{Time: health.Time(result.Time), Description: description, Name: result.ID.String(), Hostname: result.ID.String(), Type: "PEER", Available: result.Available})
+ events.Add(
+ health.Event{
+ Time: health.Time(result.Time),
+ Description: description,
+ Name: result.ID.String(),
+ Hostname: result.ID.String(),
+ Type: "PEER",
+ Available: result.Available})
}
}
diff --git a/traffic_monitor/manager/statecombiner.go b/traffic_monitor/manager/statecombiner.go
index 922b696..23611de 100644
--- a/traffic_monitor/manager/statecombiner.go
+++ b/traffic_monitor/manager/statecombiner.go
@@ -131,7 +131,16 @@ func combineCacheState(
}
if overrideCondition != "" {
- events.Add(health.Event{Time: health.Time(time.Now()), Description: fmt.Sprintf("Health protocol override condition %s", overrideCondition), Name: cacheName.String(), Hostname: cacheName.String(), Type: toData.ServerTypes[cacheName].String(), Available: available, IPv4Available: ipv4Available, IPv6Available: ipv6Available})
+ events.Add(
+ health.Event{
+ Time: health.Time(time.Now()),
+ Description: fmt.Sprintf("Health protocol override condition %s", overrideCondition),
+ Name: cacheName.String(),
+ Hostname: cacheName.String(),
+ Type: toData.ServerTypes[cacheName].String(),
+ Available: available,
+ IPv4Available: ipv4Available,
+ IPv6Available: ipv6Available})
}
combinedStates.AddCache(cacheName, tc.IsAvailable{IsAvailable: available, Ipv4Available: ipv4Available, Ipv6Available: ipv6Available})