From 96afe89c763d10b017e48e5733dc10f041f32411 Mon Sep 17 00:00:00 2001 From: Robert O Butts Date: Tue, 7 Sep 2021 15:04:08 -0600 Subject: [PATCH] Fix t3c update when fallback occurs (#6169) --- CHANGELOG.md | 1 + cache-config/t3cutil/toreq/client.go | 5 +++++ cache-config/t3cutil/toreq/toreqold/client.go | 4 ++++ cache-config/t3cutil/toreq/toreqold/clientfuncs.go | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53321c566a..6d796105d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#6027](https://github.com/apache/trafficcontrol/issues/6027) - Collapsed DB migrations - [#6091](https://github.com/apache/trafficcontrol/issues/6091) - Fixed cache config of internal cache communication for https origins - [#6066](https://github.com/apache/trafficcontrol/issues/6066) - Fixed missing/incorrect indices on some tables +- [#6169](https://github.com/apache/trafficcontrol/issues/6169) - Fixed t3c-update not updating server status when a fallback to a previous Traffic Ops API version occurred - [#5576](https://github.com/apache/trafficcontrol/issues/5576) - Inconsistent Profile Name restrictions - Fixed Federations IMS so TR federations watcher will get updates. diff --git a/cache-config/t3cutil/toreq/client.go b/cache-config/t3cutil/toreq/client.go index b73844c199..0f21b16755 100644 --- a/cache-config/t3cutil/toreq/client.go +++ b/cache-config/t3cutil/toreq/client.go @@ -104,6 +104,11 @@ func New(url *url.URL, user string, pass string, insecure bool, timeout time.Dur } client.c = nil client.old = oldClient + + { + newClient := toclient.NewNoAuthSession("", false, "", false, 0) // only used for the version, because toClient could be nil if it had an error + log.Infof("cache-config Traffic Ops client: %v not supported, falling back to %v\n", newClient.APIVersion(), oldClient.APIVersion()) + } } return client, nil diff --git a/cache-config/t3cutil/toreq/toreqold/client.go b/cache-config/t3cutil/toreq/toreqold/client.go index 98d17c24a0..5b716fcba9 100644 --- a/cache-config/t3cutil/toreq/toreqold/client.go +++ b/cache-config/t3cutil/toreq/toreqold/client.go @@ -49,6 +49,10 @@ func (cl *TOClient) SetURL(newURL string) { cl.c.URL = newURL } +func (cl *TOClient) APIVersion() string { + return cl.c.APIVersion() +} + // New logs into Traffic Ops, returning the TOClient which contains the logged-in client. func New(url *url.URL, user string, pass string, insecure bool, timeout time.Duration, userAgent string) (*TOClient, error) { log.Infoln("URL: '" + url.String() + "' User: '" + user + "' Pass len: '" + strconv.Itoa(len(pass)) + "'") diff --git a/cache-config/t3cutil/toreq/toreqold/clientfuncs.go b/cache-config/t3cutil/toreq/toreqold/clientfuncs.go index b65d46c0b5..13952387b3 100644 --- a/cache-config/t3cutil/toreq/toreqold/clientfuncs.go +++ b/cache-config/t3cutil/toreq/toreqold/clientfuncs.go @@ -570,7 +570,7 @@ func (cl *TOClient) GetServerUpdateStatus(cacheHostName tc.CacheName) (tc.Server func (cl *TOClient) SetServerUpdateStatus(cacheHostName tc.CacheName, updateStatus *bool, revalStatus *bool) (toclientlib.ReqInf, error) { reqInf := toclientlib.ReqInf{} err := torequtil.GetRetry(cl.NumRetries, "server_update_status_"+string(cacheHostName), nil, func(obj interface{}) error { - _, toReqInf, err := cl.c.GetServerUpdateStatus(string(cacheHostName)) + toReqInf, err := cl.c.SetUpdateServerStatuses(string(cacheHostName), updateStatus, revalStatus) if err != nil { return errors.New("setting server update status from Traffic Ops '" + torequtil.MaybeIPStr(reqInf.RemoteAddr) + "': " + err.Error()) }