rob05c commented on a change in pull request #3053: Traffic Monitor Disk Support
URL: https://github.com/apache/trafficcontrol/pull/3053#discussion_r240342432
##########
File path: traffic_monitor/towrap/towrap.go
##########
@@ -229,16 +244,36 @@ func (s *TrafficOpsSessionThreadsafe) CRConfigValid(crc
*tc.CRConfig, cdn string
// CRConfigRaw returns the CRConfig from the Traffic Ops. This is safe for
multiple goroutines.
func (s TrafficOpsSessionThreadsafe) CRConfigRaw(cdn string) ([]byte, error) {
+
ss := s.get()
+
+ var b []byte
+ var err error
+ var remoteAddr string
+ var reqInf client.ReqInf
+
if ss == nil {
return nil, ErrNilSession
+ } else {
+ b, reqInf, err = ss.GetCRConfig(cdn)
+ if err == nil {
+ remoteAddr = reqInf.RemoteAddr.String()
+ ioutil.WriteFile(s.CrConfigBackupFile, b, 0644)
+ } else {
+ if s.BackupFileExists() {
+ b, _ = ioutil.ReadFile(s.CrConfigBackupFile)
+ remoteAddr = "127.0.0.1"
+ log.Errorln("Error getting CRConfig from
traffic_ops, backup file exists, reading from file")
+ } else {
+ return nil, ErrNilSession
+ }
+ }
}
- b, reqInf, err := ss.GetCRConfig(cdn)
- hist := &CRConfigStat{time.Now(), reqInf.RemoteAddr.String(),
tc.CRConfigStats{}, err}
+ hist := &CRConfigStat{time.Now(), remoteAddr, tc.CRConfigStats{}, err}
defer s.crConfigHist.Add(hist)
- if err != nil {
+ if err != nil && remoteAddr != "127.0.0.1" {
Review comment:
Since `"127.0.0.1"` is used multiple times, it should probably be put in a
`const`, too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services