rob05c commented on code in PR #6883:
URL: https://github.com/apache/trafficcontrol/pull/6883#discussion_r916196067
##########
cache-config/t3cutil/getdatacfg.go:
##########
@@ -173,15 +177,27 @@ func MakeReqMetaData(respHdr http.Header) ReqMetaData {
//
// The cacheHostName is the hostname of the cache to get config generation
data for.
//
+// The oldCfg is previous config data which was cached. May be nil, if the
caller has no previous data.
+// If it exists and is usable, If-Modified-Since requests will be made and the
cache re-used where possible.
+//
+// The version is a unique version of the application, which should change
with any compatibility changes.
+// Old config with a different version than the current won't be used (though
in the future, smarter compatibility could be added).
+//
// The revalOnly arg is whether to only get data necessary to revalidate,
versus all data necessary to generate cache config.
-func GetConfigData(toClient *toreq.TOClient, disableProxy bool, cacheHostName
string, revalOnly bool, oldCfg *ConfigData) (*ConfigData, error) {
+func GetConfigData(toClient *toreq.TOClient, disableProxy bool, cacheHostName
string, revalOnly bool, oldCfg *ConfigData, version string) (*ConfigData,
error) {
start := time.Now()
defer func() { log.Infof("GetTOData took %v\n", time.Since(start)) }()
toIPs := &sync.Map{} // each Traffic Ops request could get a different
IP, so track them all
toData := &ConfigData{}
+ toData.Version = version
toData.MetaData.CacheHostName = cacheHostName
+ if oldCfg != nil && oldCfg.Version != toData.Version {
+ log.Infof("old config version '%v' doesn't match current
version '%v', old config will not be used!\n", oldCfg.Version, toData.Version)
Review Comment:
For the record, I don't agree, in my opinion it reduces readability without
increasing safety. It also makes this code not idiomatic with the rest of t3c
and lib/go-atscfg.
But it's more important to get this fix in. Changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]