ocket8888 commented on code in PR #6883:
URL: https://github.com/apache/trafficcontrol/pull/6883#discussion_r892696349


##########
cache-config/t3cutil/getdata.go:
##########
@@ -54,6 +54,10 @@ type TCCfg struct {
 
        // OldCfg is the previously fetched ConfigData, for 'config' requests. 
May be nil.
        OldCfg *ConfigData
+
+       // T3cVersion is the version of the t3c app ecosystem

Review Comment:
   should be a capital "C" to match the field name



##########
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 best safety at compile-time, format-strings should use the most 
specific formatting parameter possible - `%s` in this case.



##########
cache-config/t3cutil/getdata.go:
##########
@@ -54,6 +54,10 @@ type TCCfg struct {
 
        // OldCfg is the previously fetched ConfigData, for 'config' requests. 
May be nil.
        OldCfg *ConfigData
+
+       // T3cVersion is the version of the t3c app ecosystem
+       // This value will be the same for any t3c app.
+       T3CVersion string

Review Comment:
   Should this be override-able through the configuration file? It just seems a 
little strange to tell a utility which could be wrong when the utility 
ostensibly always knows the correct value.



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

Reply via email to