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:01:51 UTC

[trafficcontrol] 03/08: Fix atscfg comparing pointers not values (#5536)

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

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

commit dc81fdff9055e08f2589ecf0907795c4acebac5f
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Mon Mar 15 11:40:45 2021 -0600

    Fix atscfg comparing pointers not values (#5536)
    
    (cherry picked from commit 7c8fae62ed6869136946db362e80c0251d5beb5b)
---
 CHANGELOG.md                                    |  1 +
 lib/go-atscfg/headerrewritemiddotconfig.go      |  2 +-
 lib/go-atscfg/headerrewritemiddotconfig_test.go | 20 ++++++++++++++------
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0aa9949..230a1b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 ### Fixed
 - [#5565](https://github.com/apache/trafficcontrol/issues/5565) - TO GET /caches/stats panic converting string to uint64
 - [#5558](https://github.com/apache/trafficcontrol/issues/5558) - Fixed `TM UI` and `/api/cache-statuses` to report aggregate `bandwidth_kbps` correctly.
+- - Fix for config gen missing max_origin_connections on mids in certain scenarios
 
 ## [5.1.0] - 2021-02-21
 ### Added
diff --git a/lib/go-atscfg/headerrewritemiddotconfig.go b/lib/go-atscfg/headerrewritemiddotconfig.go
index f4e7947..d0a6bf4 100644
--- a/lib/go-atscfg/headerrewritemiddotconfig.go
+++ b/lib/go-atscfg/headerrewritemiddotconfig.go
@@ -94,7 +94,7 @@ func MakeHeaderRewriteMidDotConfig(
 			continue
 		}
 
-		if sv.CDNName != server.CDNName {
+		if *sv.CDNName != *server.CDNName {
 			continue
 		}
 		if _, ok := assignedServers[*sv.ID]; !ok && (tcDS.Topology == nil || *tcDS.Topology == "") {
diff --git a/lib/go-atscfg/headerrewritemiddotconfig_test.go b/lib/go-atscfg/headerrewritemiddotconfig_test.go
index b6203a5..92cf693 100644
--- a/lib/go-atscfg/headerrewritemiddotconfig_test.go
+++ b/lib/go-atscfg/headerrewritemiddotconfig_test.go
@@ -32,39 +32,47 @@ func TestMakeHeaderRewriteMidDotConfig(t *testing.T) {
 	hdr := "myHeaderComment"
 
 	server := makeGenericServer()
-	server.CDNName = &cdnName
+	server.CDNName = util.StrPtr(cdnName)
 	server.Cachegroup = util.StrPtr("edgeCG")
 	server.HostName = util.StrPtr("myserver")
 	serverStatus := string(tc.CacheStatusReported)
 	server.Status = &serverStatus
 
+	// server, as inserted in servers.
+	// needs to be different, so the pointers are different, like they will be with different API calls.
+	serverSvs := makeGenericServer()
+	serverSvs.CDNName = util.StrPtr(cdnName)
+	serverSvs.Cachegroup = util.StrPtr("edgeCG")
+	serverSvs.HostName = util.StrPtr("myserver")
+	serverSvs.Status = util.StrPtr(string(tc.CacheStatusReported))
+
 	ds := makeGenericDS()
 	ds.EdgeHeaderRewrite = util.StrPtr("edgerewrite")
 	ds.ID = util.IntPtr(24)
 	ds.XMLID = util.StrPtr("ds0")
 	ds.MaxOriginConnections = util.IntPtr(42)
 	ds.MidHeaderRewrite = util.StrPtr("midrewrite")
-	ds.CDNName = &cdnName
+	ds.CDNName = util.StrPtr(cdnName)
 	dsType := tc.DSTypeHTTP
 	ds.Type = &dsType
 	ds.ServiceCategory = util.StrPtr("servicecategory")
 
 	mid0 := makeGenericServer()
-	mid0.CDNName = &cdnName
+	mid0.CDNName = util.StrPtr(cdnName)
 	mid0.Cachegroup = util.StrPtr("midCG")
 	mid0.HostName = util.StrPtr("mymid0")
 	mid0Status := string(tc.CacheStatusReported)
 	mid0.Status = &mid0Status
 
 	mid1 := makeGenericServer()
-	mid1.CDNName = &cdnName
+	mid1.CDNName = util.StrPtr(cdnName)
 	mid1.Cachegroup = util.StrPtr("midCG")
 	mid1.HostName = util.StrPtr("mymid1")
 	mid1Status := string(tc.CacheStatusOnline)
 	mid1.Status = &mid1Status
 
 	mid2 := makeGenericServer()
-	mid2.CDNName = &cdnName
+	mid2.CDNName = util.StrPtr(cdnName)
 	mid2.Cachegroup = util.StrPtr("midCG")
 	mid2.HostName = util.StrPtr("mymid2")
 	mid2Status := string(tc.CacheStatusOffline)
@@ -85,7 +93,7 @@ func TestMakeHeaderRewriteMidDotConfig(t *testing.T) {
 	mCG.Type = &mCGType
 
 	cgs := []tc.CacheGroupNullable{*eCG, *mCG}
-	servers := []Server{*server, *mid0, *mid1, *mid2}
+	servers := []Server{*serverSvs, *mid0, *mid1, *mid2}
 	dses := []DeliveryService{*ds}
 	dss := makeDSS(servers, dses)