You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/03/19 18:02:14 UTC

[trafficcontrol] branch master updated: Fix ORT to fallback to previous TO minors (#5642)

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 16aa12b  Fix ORT to fallback to previous TO minors (#5642)
16aa12b is described below

commit 16aa12be46f51efda867c4a6a5b50c6ddc47906a
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Fri Mar 19 12:02:05 2021 -0600

    Fix ORT to fallback to previous TO minors (#5642)
---
 CHANGELOG.md                                |  1 +
 traffic_ops_ort/atstccfg/toreq/client.go    | 16 ++++++++++------
 traffic_ops_ort/atstccfg/toreqold/client.go | 12 ++++++++----
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8060f13..23fa347 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -98,6 +98,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 - Fixed an issue with 2020082700000000_server_id_primary_key.sql trying to create multiple primary keys when there are multiple schemas.
 - Fix for public schema in 2020062923101648_add_deleted_tables.sql
 - Fix for config gen missing max_origin_connections on mids in certain scenarios
+- [#5642](https://github.com/apache/trafficcontrol/issues/5642) - Fixed ORT to fall back to previous minor Traffic Ops versions, allowing ORT to be upgraded before Traffic Ops when the minor has changed.
 - Moved move_lets_encrypt_to_acme.sql, add_max_request_header_size_delivery_service.sql, and server_interface_ip_address_cascade.sql past last migration in 5.0.0
 - [#5505](https://github.com/apache/trafficcontrol/issues/5505) - Make `parent_reval_pending` for servers in a Flexible Topology CDN-specific on `GET /servers/{name}/update_status`
 - [#5317](https://github.com/apache/trafficcontrol/issues/5317) - Clicking IP addresses in the servers table no longer navigates to server details page.
diff --git a/traffic_ops_ort/atstccfg/toreq/client.go b/traffic_ops_ort/atstccfg/toreq/client.go
index 475a6ab..5845d39 100644
--- a/traffic_ops_ort/atstccfg/toreq/client.go
+++ b/traffic_ops_ort/atstccfg/toreq/client.go
@@ -51,16 +51,20 @@ type TOClient struct {
 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)) + "'")
 
-	toFQDN := url.Scheme + "://" + url.Host
-	log.Infoln("TO FQDN: '" + toFQDN + "'")
+	toURLStr := url.Scheme + "://" + url.Host
+	log.Infoln("TO URL string: '" + toURLStr + "'")
 	log.Infoln("TO URL: '" + url.String() + "'")
 
-	toClient, toIP, err := toclient.LoginWithAgent(toFQDN, user, pass, insecure, userAgent, false, timeout)
+	opts := toclient.ClientOpts{}
+	opts.Insecure = insecure
+	opts.UserAgent = userAgent
+	opts.RequestTimeout = timeout
+	toClient, inf, err := toclient.Login(toURLStr, user, pass, opts)
 	if err != nil {
-		return nil, errors.New("Logging in to Traffic Ops '" + torequtil.MaybeIPStr(toIP) + "': " + err.Error())
+		return nil, errors.New("Logging in to Traffic Ops '" + torequtil.MaybeIPStr(inf.RemoteAddr) + "': " + err.Error())
 	}
 
-	log.Infoln("toreqnew.New Logged into in to Traffic Ops '" + torequtil.MaybeIPStr(toIP) + "'")
+	log.Infoln("toreqnew.New Logged into in to Traffic Ops '" + torequtil.MaybeIPStr(inf.RemoteAddr) + "'")
 
 	latestSupported, toAddr, err := IsLatestSupported(toClient)
 	if err != nil {
@@ -69,7 +73,7 @@ func New(url *url.URL, user string, pass string, insecure bool, timeout time.Dur
 
 	client := &TOClient{C: toClient}
 	if !latestSupported {
-		log.Warnln("toreqnew.New Traffic Ops '" + torequtil.MaybeIPStr(toIP) + "' does not support the latest client, falling back ot the previous")
+		log.Warnln("toreqnew.New Traffic Ops '" + torequtil.MaybeIPStr(inf.RemoteAddr) + "' does not support the latest client, falling back ot the previous")
 
 		oldClient, err := toreqold.New(url, user, pass, insecure, timeout, userAgent)
 		if err != nil {
diff --git a/traffic_ops_ort/atstccfg/toreqold/client.go b/traffic_ops_ort/atstccfg/toreqold/client.go
index 3eb52b9..c0b141e 100644
--- a/traffic_ops_ort/atstccfg/toreqold/client.go
+++ b/traffic_ops_ort/atstccfg/toreqold/client.go
@@ -47,13 +47,17 @@ const isFallback = true
 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)) + "'")
 
-	toFQDN := url.Scheme + "://" + url.Host
-	log.Infoln("TO FQDN: '" + toFQDN + "'")
+	toURLStr := url.Scheme + "://" + url.Host
+	log.Infoln("TO URL string: '" + toURLStr + "'")
 	log.Infoln("TO URL: '" + url.String() + "'")
 
-	toClient, toIP, err := toclient.LoginWithAgent(toFQDN, user, pass, insecure, userAgent, false, timeout)
+	opts := toclient.ClientOpts{}
+	opts.Insecure = insecure
+	opts.UserAgent = userAgent
+	opts.RequestTimeout = timeout
+	toClient, inf, err := toclient.Login(toURLStr, user, pass, opts)
 	if err != nil {
-		return nil, errors.New("Logging in to Traffic Ops '" + torequtil.MaybeIPStr(toIP) + "': " + err.Error())
+		return nil, errors.New("Logging in to Traffic Ops '" + torequtil.MaybeIPStr(inf.RemoteAddr) + "': " + err.Error())
 	}
 
 	return &TOClient{C: toClient}, nil