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

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

commit 69709ced3c67aafec9211d8862ce13c16b975c61
Author: Evan Zelkowitz <[email protected]>
AuthorDate: Tue Sep 7 14:01:14 2021 -0600

    T3c hosting (#6166)
    
    * Add a continue in the case the DS is not a LIVE service, so that it does 
not get added to the ramdisk hosting list
    
    * Fix spacing
    
    * Also remove topology nil check for live services. Fix tests so that the 
first is checking for a ram entry with a live service instead of non-live, 
second checks for no ramdisk entry
    
    * We still need the non-topology assigned check
    
    * Change text comparison to use helper function
    
    (cherry picked from commit 739c80a0baa4a27af1c8d95cd372a38c95655865)
---
 lib/go-atscfg/hostingdotconfig.go      | 28 +++++++++++++++++-----------
 lib/go-atscfg/hostingdotconfig_test.go |  2 +-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/go-atscfg/hostingdotconfig.go 
b/lib/go-atscfg/hostingdotconfig.go
index d81b9cd..611d93d 100644
--- a/lib/go-atscfg/hostingdotconfig.go
+++ b/lib/go-atscfg/hostingdotconfig.go
@@ -125,25 +125,28 @@ func MakeHostingDotConfig(
                if *ds.CDNID != *server.CDNID {
                        continue
                }
-               if ds.Topology == nil {
-                       if !*ds.Active && ((!isMid && 
!ServerHostingDotConfigEdgeIncludeInactive) || (isMid && 
!ServerHostingDotConfigMidIncludeInactive)) {
+
+               if !*ds.Active && ((!isMid && 
!ServerHostingDotConfigEdgeIncludeInactive) || (isMid && 
!ServerHostingDotConfigMidIncludeInactive)) {
+                       continue
+               }
+
+               if isMid {
+                       if !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveNationalSuffix) {
                                continue
                        }
 
-                       if isMid {
-                               if !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveNationalSuffix) {
-                                       continue
-                               }
-
+                       if ds.Topology == nil {
                                // mids: include all DSes with at least one 
server assigned
                                if len(dsServerMap[*ds.ID]) == 0 {
                                        continue
                                }
-                       } else {
-                               if !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveNationalSuffix) && !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveSuffix) {
-                                       continue
-                               }
+                       }
+               } else {
+                       if !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveNationalSuffix) && !strings.HasSuffix(string(*ds.Type), 
tc.DSTypeLiveSuffix) {
+                               continue
+                       }
 
+                       if ds.Topology == nil {
                                // edges: only include DSes assigned to this 
edge
                                if dsServerMap[*ds.ID] == nil {
                                        continue
@@ -196,6 +199,9 @@ func MakeHostingDotConfig(
                                        if !topoHasServer {
                                                continue
                                        }
+                                       if !ds.Type.IsLive() {
+                                               continue
+                                       }
                                }
                        }
 
diff --git a/lib/go-atscfg/hostingdotconfig_test.go 
b/lib/go-atscfg/hostingdotconfig_test.go
index 1f0d0f6..c58b4cf 100644
--- a/lib/go-atscfg/hostingdotconfig_test.go
+++ b/lib/go-atscfg/hostingdotconfig_test.go
@@ -159,7 +159,7 @@ func TestMakeHostingDotConfigTopologiesIgnoreDSS(t 
*testing.T) {
        dsTopology.ID = util.IntPtr(900)
        dsTopology.Topology = util.StrPtr("t0")
        dsTopology.Active = util.BoolPtr(true)
-       dsType := tc.DSTypeHTTP
+       dsType := tc.DSTypeHTTPLive
        dsTopology.Type = &dsType
 
        dsTopologyWithoutServer := makeGenericDS()

Reply via email to