rob05c commented on a change in pull request #3053: Traffic Monitor Disk Support
URL: https://github.com/apache/trafficcontrol/pull/3053#discussion_r240339772
 
 

 ##########
 File path: traffic_monitor/towrap/towrap.go
 ##########
 @@ -277,8 +312,30 @@ func (s TrafficOpsSessionThreadsafe) 
trafficMonitorConfigMapRaw(cdn string) (*tc
        if ss == nil {
                return nil, ErrNilSession
        }
-       configMap, _, error := ss.GetTrafficMonitorConfigMap(cdn)
-       return configMap, error
+       var configMap *tc.TrafficMonitorConfigMap
+       var err error
+
+       configMap, _, err = ss.GetTrafficMonitorConfigMap(cdn)
+       if configMap != nil {
+               json := jsoniter.ConfigFastest
+               data, err := json.Marshal(*configMap)
+               if err == nil {
+                       ioutil.WriteFile(s.TmConfigBackupFile, data, 0644)
+               }
+       } else {
+               if s.BackupFileExists() {
+                       b, _ := ioutil.ReadFile(s.TmConfigBackupFile)
+                       log.Errorln("Error getting configMap from traffic_ops, 
backup file exists, reading from file")
+                       json := jsoniter.ConfigFastest
+                       err = json.Unmarshal(b, &configMap)
+                       if err != nil {
+                               log.Warnf("Error unmarshaling 
TmConfigBackupFile, ", err)
 
 Review comment:
   Should this really be a warning? Not an error log? And not returned?
   
   At this point, we both failed to get from TO and failed to read the file, 
right? That seems like it should return from this func, so the calling handler 
can deal with that.

----------------------------------------------------------------
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

Reply via email to