Skip to content

Commit

Permalink
Improvement to TCHC's logging around TO failure (#7776)
Browse files Browse the repository at this point in the history
* Adding status code for TO

* Adding improved logging for TO interaction

* Adding revised Change log.

* Fixing arg issues.

---------

Co-authored-by: Tyler Morgan <tylermorgan210@gmail.com>
  • Loading branch information
cybertunnel and Tyler Morgan committed Sep 11, 2023
1 parent b31e003 commit 890f3b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7784](https://github.com/apache/trafficcontrol/pull/7784) *Traffic Portal* Added revert certificate functionality to the ssl-keys page.

### Changed
- [#7776](https://github.com/apache/trafficcontrol/pull/7776) *tc-health-client* Added error message while issues interacting with Traffic Ops.
- [#7757](https://github.com/apache/trafficcontrol/pull/7757) *Traffic Router* Changed Traffic Router to point to api version 5.0 of Traffic Ops.
- [#7732](https://github.com/apache/trafficcontrol/pull/7732) *Traffic Router* Increased negative TTL value to 900 seconds.
- [#7761](https://github.com/apache/trafficcontrol/pull/7761) *Traffic Monitor* Use API v5 for the TM's Traffic Ops client, and use TO API v4 for TM's Traffic Ops legacy client
Expand Down
4 changes: 2 additions & 2 deletions tc-health-client/tc-health-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ func reloadConfig(pi *tmagent.ParentInfo) {

if isNew {
if err = config.ReadCredentials(newCfg, false); err != nil {
log.Errorln("could not load credentials for config updates, keeping the old config")
log.Errorf("could not load credentials for config updates, keeping the old config: %v", err.Error())
return
}
if err = pi.GetTOData(newCfg); err != nil {
log.Errorln("could not update the list of trafficmonitors, keeping the old config")
log.Errorf("could not update the list of trafficmonitors, keeping the old config: %v", err.Error())
} else {
// TODO this was calling a custom copy func that wasn't copying:
// MarkUpPollThreshold, TmProxyURL, CredentialFile, ParsedProxyURL
Expand Down
5 changes: 4 additions & 1 deletion tc-health-client/tmagent/tmagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,15 @@ func (pi *ParentInfo) GetTOData(cfg *config.Cfg) error {
}
}

srvs, _, err := toData.TOClient.GetServers(toclient.NewRequestOptions())
srvs, reqInf, err := toData.TOClient.GetServers(toclient.NewRequestOptions())
if err != nil {
// next time we'll login again and get a new session.
toData.TOClient = nil
pi.TOData.Set(toData)
return errors.New("error fetching Trafficmonitor server list: " + err.Error())
} else if reqInf.StatusCode >= 300 || reqInf.StatusCode < 200 {
// Provide logging around a potential issue
return fmt.Errorf("Traffic Ops returned a non 2xx status code. Expected 2xx, got %v", reqInf.StatusCode)
}

toData.Monitors = map[string]struct{}{}
Expand Down
4 changes: 2 additions & 2 deletions tc-health-client/tmagent/tmhealthservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func doPollAndUpdateCacheStatus(pi *ParentInfo, doTrafficOpsReq bool) {
if err != nil {
log.Errorf("poll-status %v\n", err.Error())
if err := pi.GetTOData(cfg); err != nil {
log.Errorln("update event=\"could not update the list of trafficmonitors, keeping the old config\"")
log.Errorf("update event=\"could not update the list of trafficmonitors, keeping the old config\": %v", err.Error())
} else {
log.Infoln("service-status service=tm-health event=\"updated TrafficMonitor statuses from TrafficOps\"")
}
Expand All @@ -132,7 +132,7 @@ func doPollAndUpdateCacheStatus(pi *ParentInfo, doTrafficOpsReq bool) {
if doTrafficOpsReq {
// TODO move to its own TO poller
if err = pi.GetTOData(cfg); err != nil {
log.Errorln("update event=\"could not update the list of trafficmonitors, keeping the old config\"")
log.Errorf("update event=\"could not update the list of trafficmonitors, keeping the old config\": %v", err.Error())
} else {
log.Infoln("service-status service=tm-health event=\"updated TrafficMonitor statuses from TrafficOps\"")
}
Expand Down

0 comments on commit 890f3b4

Please sign in to comment.