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/05/06 16:53:51 UTC
[trafficcontrol] branch 5.1.x updated: Add atscfg mid header
rewrite service category (#5815)
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
The following commit(s) were added to refs/heads/5.1.x by this push:
new 45510e7 Add atscfg mid header rewrite service category (#5815)
45510e7 is described below
commit 45510e7f9477cea2b011ea33d523d21e29f5704d
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Thu May 6 10:53:31 2021 -0600
Add atscfg mid header rewrite service category (#5815)
Also adds to topology header rewrites, and fixes edge injection
to be before custom rewrite to prevent potential [L] issues.
---
CHANGELOG.md | 1 +
lib/go-atscfg/headerrewritedotconfig.go | 16 +++++-----------
lib/go-atscfg/headerrewritemiddotconfig.go | 11 +++++------
lib/go-atscfg/headerrewritemiddotconfig_test.go | 3 +++
lib/go-atscfg/topologyheaderrewritedotconfig.go | 11 +++++------
5 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8c0eab0..d727704 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed the return error for GET api `cdns/routing` to avoid incorrect success response.
- [#5712](https://github.com/apache/trafficcontrol/issues/5712) - Ensure that 5.x Traffic Stats is compatible with 5.x Traffic Monitor and 5.x Traffic Ops, and that it doesn't log all 0's for `cache_stats`
- Fixed ORT being unable to update URLSIG keys for Delivery Services
+- Fixed ORT service category header rewrite for mids and topologies.
- Fixed an issue where Traffic Ops becoming unavailable caused Traffic Monitor to segfault and crash
- [#5754](https://github.com/apache/trafficcontrol/issues/5754) - Ensure Health Threshold Parameters use legacy format for legacy Monitoring Config handler
- [#5695](https://github.com/apache/trafficcontrol/issues/5695) - Ensure vitals are calculated only against monitored interfaces
diff --git a/lib/go-atscfg/headerrewritedotconfig.go b/lib/go-atscfg/headerrewritedotconfig.go
index 4d6a0ef..5bc1241 100644
--- a/lib/go-atscfg/headerrewritedotconfig.go
+++ b/lib/go-atscfg/headerrewritedotconfig.go
@@ -21,7 +21,6 @@ package atscfg
import (
"errors"
- "fmt"
"math"
"regexp"
"strconv"
@@ -133,25 +132,20 @@ func MakeHeaderRewriteDotConfig(
if dsOnlineEdgeCount > 0 {
maxOriginConnectionsPerEdge := int(math.Round(float64(ds.MaxOriginConnections) / float64(dsOnlineEdgeCount)))
- text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerEdge)
- if ds.EdgeHeaderRewrite == "" {
- text += " [L]"
- } else {
- text += "\n"
- }
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerEdge) + "\n"
}
}
+ if !strings.Contains(ds.EdgeHeaderRewrite, ServiceCategoryHeader) && ds.ServiceCategory != "" {
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-header " + ServiceCategoryHeader + ` "` + dsName + "|" + ds.ServiceCategory + `"` + "\n"
+ }
+
// write the contents of ds.EdgeHeaderRewrite to hdr_rw_xml-id.config replacing any instances of __RETURN__ (surrounded by spaces or not) with \n
if ds.EdgeHeaderRewrite != "" {
re := regexp.MustCompile(`\s*__RETURN__\s*`)
text += re.ReplaceAllString(ds.EdgeHeaderRewrite, "\n")
}
- if !strings.Contains(text, ServiceCategoryHeader) && ds.ServiceCategory != "" {
- text += fmt.Sprintf("\nset-header %s \"%s|%s\"", ServiceCategoryHeader, dsName, ds.ServiceCategory)
- }
-
text += "\n"
return Cfg{
diff --git a/lib/go-atscfg/headerrewritemiddotconfig.go b/lib/go-atscfg/headerrewritemiddotconfig.go
index d0a6bf4..3d288d8 100644
--- a/lib/go-atscfg/headerrewritemiddotconfig.go
+++ b/lib/go-atscfg/headerrewritemiddotconfig.go
@@ -157,15 +157,14 @@ func MakeHeaderRewriteMidDotConfig(
}
if dsOnlineMidCount > 0 {
maxOriginConnectionsPerMid := int(math.Round(float64(ds.MaxOriginConnections) / float64(dsOnlineMidCount)))
- text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerMid)
- if ds.MidHeaderRewrite == "" {
- text += " [L]"
- } else {
- text += "\n"
- }
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerMid) + "\n"
}
}
+ if !strings.Contains(ds.MidHeaderRewrite, ServiceCategoryHeader) && ds.ServiceCategory != "" {
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-header " + ServiceCategoryHeader + ` "` + dsName + "|" + ds.ServiceCategory + `"` + "\n"
+ }
+
// write the contents of ds.MidHeaderRewrite to hdr_rw_mid_xml-id.config replacing any instances of __RETURN__ (surrounded by spaces or not) with \n
if ds.MidHeaderRewrite != "" {
re := regexp.MustCompile(`\s*__RETURN__\s*`)
diff --git a/lib/go-atscfg/headerrewritemiddotconfig_test.go b/lib/go-atscfg/headerrewritemiddotconfig_test.go
index 92cf693..f3ebf89 100644
--- a/lib/go-atscfg/headerrewritemiddotconfig_test.go
+++ b/lib/go-atscfg/headerrewritemiddotconfig_test.go
@@ -205,4 +205,7 @@ func TestMakeHeaderRewriteMidDotConfigNoMaxConns(t *testing.T) {
if strings.Contains(txt, "origin_max_connections") {
t.Errorf("expected no origin_max_connections on edge-only DS, actual '%v'\n", txt)
}
+ if !strings.Contains(txt, "ds0|servicecategory") {
+ t.Errorf("expected 'ds0|servicecategory' actual '%v'\n", txt)
+ }
}
diff --git a/lib/go-atscfg/topologyheaderrewritedotconfig.go b/lib/go-atscfg/topologyheaderrewritedotconfig.go
index 32d1008..62b292f 100644
--- a/lib/go-atscfg/topologyheaderrewritedotconfig.go
+++ b/lib/go-atscfg/topologyheaderrewritedotconfig.go
@@ -144,12 +144,11 @@ func MakeTopologyHeaderRewriteDotConfig(
maxOriginConnectionsPerServer = 1
}
- text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerServer)
- if headerRewrite == nil || *headerRewrite == "" {
- text += " [L]"
- } else {
- text += "\n"
- }
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-config proxy.config.http.origin_max_connections " + strconv.Itoa(maxOriginConnectionsPerServer) + "\n"
+ }
+
+ if (headerRewrite == nil || !strings.Contains(*headerRewrite, ServiceCategoryHeader)) && ds.ServiceCategory != nil && *ds.ServiceCategory != "" {
+ text += "cond %{REMAP_PSEUDO_HOOK}\nset-header " + ServiceCategoryHeader + ` "` + dsName + "|" + *ds.ServiceCategory + `"` + "\n"
}
if headerRewrite != nil && *headerRewrite != "" {