You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2022/05/23 20:06:33 UTC
[trafficcontrol] branch master updated: Change t3c non-topo non-parent line to origin (#6848)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman 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 a1c09e7808 Change t3c non-topo non-parent line to origin (#6848)
a1c09e7808 is described below
commit a1c09e7808ab3e77fe4a47ce8e0901c76778f16d
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Mon May 23 14:06:28 2022 -0600
Change t3c non-topo non-parent line to origin (#6848)
Previously, t3c non-topology DSes which didn't use parents would omit
the parent= from the parent.config line. The ATS docs seem to
indicate that should have worked, but it seems to only work for very
specific settings, e.g. parent_is_proxy=false made the line break
(along with potentially other settings).
This changes those DSes to set parent=origin, which appears to make
ATS behave correctly with parent_is_proxy, go_direct, and other
necessary settings.
Note Topology DSes were already doing this, this effectively
changes non-topo to match topo generation.
---
lib/go-atscfg/parentdotconfig.go | 7 ++
lib/go-atscfg/parentdotconfig_test.go | 117 ++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+)
diff --git a/lib/go-atscfg/parentdotconfig.go b/lib/go-atscfg/parentdotconfig.go
index 8f1491e4f1..b57a920720 100644
--- a/lib/go-atscfg/parentdotconfig.go
+++ b/lib/go-atscfg/parentdotconfig.go
@@ -535,6 +535,13 @@ func makeParentDotConfigData(
warnings = append(warnings, "DS '"+*ds.XMLID+"' had malformed origin port: '"+orgURI.Port()+"': using "+strconv.Itoa(text.Port)+"! : "+err.Error())
}
text.GoDirect = true
+
+ text.Parents = []*ParentAbstractionServiceParent{&ParentAbstractionServiceParent{
+ FQDN: text.DestDomain,
+ Port: text.Port,
+ Weight: 1.0,
+ }}
+
// text += `dest_domain=` + orgURI.Hostname() + ` port=` + orgURI.Port() + ` go_direct=true` + "\n"
} else {
diff --git a/lib/go-atscfg/parentdotconfig_test.go b/lib/go-atscfg/parentdotconfig_test.go
index d9f345c465..0df08a7292 100644
--- a/lib/go-atscfg/parentdotconfig_test.go
+++ b/lib/go-atscfg/parentdotconfig_test.go
@@ -3048,6 +3048,123 @@ func TestMakeParentDotConfigHTTPSOriginTopology(t *testing.T) {
}
}
+func TestMakeParentDotConfigNoParentNoTopology(t *testing.T) {
+ hdr := &ParentConfigOpts{AddComments: false, HdrComment: "myHeaderComment"}
+
+ ds0 := makeParentDS()
+ ds0Type := tc.DSTypeHTTPLive
+ ds0.Type = &ds0Type
+ ds0.QStringIgnore = util.IntPtr(int(tc.QStringIgnoreUseInCacheKeyAndPassUp))
+ ds0.OrgServerFQDN = util.StrPtr("http://ds0-origin.example.net")
+
+ dses := []DeliveryService{*ds0}
+
+ parentConfigParams := []tc.Parameter{
+ tc.Parameter{
+ Name: ParentConfigParamQStringHandling,
+ ConfigFile: "parent.config",
+ Value: "myQStringHandlingParam",
+ Profiles: []byte(`["serverprofile"]`),
+ },
+ tc.Parameter{
+ Name: ParentConfigParamAlgorithm,
+ ConfigFile: "parent.config",
+ Value: tc.AlgorithmConsistentHash,
+ Profiles: []byte(`["serverprofile"]`),
+ },
+ tc.Parameter{
+ Name: ParentConfigParamQString,
+ ConfigFile: "parent.config",
+ Value: "myQstringParam",
+ Profiles: []byte(`["serverprofile"]`),
+ },
+ }
+
+ serverParams := []tc.Parameter{
+ tc.Parameter{
+ Name: "trafficserver",
+ ConfigFile: "package",
+ Value: "7",
+ Profiles: []byte(`["global"]`),
+ },
+ }
+
+ server := makeTestParentServer()
+
+ mid0 := makeTestParentServer()
+ mid0.Cachegroup = util.StrPtr("midCG")
+ mid0.HostName = util.StrPtr("mymid0")
+ mid0.ID = util.IntPtr(45)
+ setIP(mid0, "192.168.2.2")
+
+ mid1 := makeTestParentServer()
+ mid1.Cachegroup = util.StrPtr("midCG")
+ mid1.HostName = util.StrPtr("mymid1")
+ mid1.ID = util.IntPtr(46)
+ setIP(mid1, "192.168.2.3")
+
+ servers := []Server{*server, *mid0, *mid1}
+
+ topologies := []tc.Topology{}
+ serverCapabilities := map[int]map[ServerCapability]struct{}{}
+ dsRequiredCapabilities := map[int]map[ServerCapability]struct{}{}
+
+ eCG := &tc.CacheGroupNullable{}
+ eCG.Name = server.Cachegroup
+ eCG.ID = server.CachegroupID
+ eCG.ParentName = mid0.Cachegroup
+ eCG.ParentCachegroupID = mid0.CachegroupID
+ eCGType := tc.CacheGroupEdgeTypeName
+ eCG.Type = &eCGType
+
+ mCG := &tc.CacheGroupNullable{}
+ mCG.Name = mid0.Cachegroup
+ mCG.ID = mid0.CachegroupID
+ mCGType := tc.CacheGroupMidTypeName
+ mCG.Type = &mCGType
+
+ cgs := []tc.CacheGroupNullable{*eCG, *mCG}
+
+ dss := []DeliveryServiceServer{
+ DeliveryServiceServer{
+ Server: *server.ID,
+ DeliveryService: *ds0.ID,
+ },
+ }
+ cdn := &tc.CDN{
+ DomainName: "cdndomain.example",
+ Name: "my-cdn-name",
+ }
+
+ cfg, err := MakeParentDotConfig(dses, server, servers, topologies, serverParams, parentConfigParams, serverCapabilities, dsRequiredCapabilities, cgs, dss, cdn, hdr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ txt := cfg.Text
+
+ testComment(t, txt, hdr.HdrComment)
+
+ if !strings.Contains(txt, "dest_domain=ds0-origin.example.net") {
+ t.Errorf("expected parent 'dest_domain=ds0-origin.example.net', actual: '%v'", txt)
+ }
+
+ lines := strings.Split(txt, "\n")
+ for _, line := range lines {
+ if !strings.Contains(line, "dest_domain=ds0-origin.example.net") {
+ continue
+ }
+ if !strings.Contains(line, `parent="ds0-origin.example.net:80`) {
+ t.Errorf("expected non-topology DS of type not using parents to have parent=origin directive, actual: '%v'", txt)
+ }
+ if !strings.Contains(line, `go_direct=true`) {
+ t.Errorf("expected non-topology DS of type not using parents to have go_direct=true directive, actual: '%v'", txt)
+ }
+ if !strings.Contains(line, `parent_is_proxy=false`) {
+ t.Errorf("expected non-topology DS of type not using parents to have parent_is_proxy=false directive, actual: '%v'", txt)
+ }
+ }
+}
+
func TestMakeParentDotConfigHTTPSOriginTopologyNoPrimaryParent(t *testing.T) {
hdr := &ParentConfigOpts{AddComments: true, HdrComment: "myHeaderComment"}