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 3564c96  Exclude ORG_LOC cachegroups from topology-based DS req. cap. 
validation (#5270)
3564c96 is described below

commit 3564c9654d4cd5f27f72d591e9197c4882d953a3
Author: Rawlin Peters <[email protected]>
AuthorDate: Tue Nov 10 17:29:00 2020 -0700

    Exclude ORG_LOC cachegroups from topology-based DS req. cap. validation 
(#5270)
    
    Server capabilities do not apply to ORG servers (origins), so the
    validation needs to exclude them.
---
 traffic_ops/testing/api/v3/tc-fixtures.json                       | 8 ++++++--
 .../deliveryservice/deliveryservices_required_capabilities.go     | 2 +-
 traffic_ops/traffic_ops_golang/topology/topologies.go             | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/traffic_ops/testing/api/v3/tc-fixtures.json 
b/traffic_ops/testing/api/v3/tc-fixtures.json
index 688ab8b..30c811f 100644
--- a/traffic_ops/testing/api/v3/tc-fixtures.json
+++ b/traffic_ops/testing/api/v3/tc-fixtures.json
@@ -4218,12 +4218,16 @@
             "description": "a topology",
             "nodes": [
                 {
-                    "cachegroup": "dtrc1",
+                    "cachegroup": "multiOriginCachegroup",
                     "parents": []
                 },
                 {
-                    "cachegroup": "dtrc2",
+                    "cachegroup": "dtrc1",
                     "parents": [0]
+                },
+                {
+                    "cachegroup": "dtrc2",
+                    "parents": [1]
                 }
             ]
         }
diff --git 
a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_required_capabilities.go
 
b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_required_capabilities.go
index 2e75315..e45e071 100644
--- 
a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_required_capabilities.go
+++ 
b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_required_capabilities.go
@@ -343,7 +343,6 @@ func (rc *RequiredCapability) checkServerCap() (error, 
error, int) {
 // EnsureTopologyBasedRequiredCapabilities ensures that at least one server 
per cachegroup
 // in this delivery service's topology has this delivery service's required 
capabilities.
 func EnsureTopologyBasedRequiredCapabilities(tx *sql.Tx, dsID int, topology 
string, requiredCapabilities []string) (error, error, int) {
-       // language=sql
        q := `
 SELECT
   s.id,
@@ -357,6 +356,7 @@ JOIN topology_cachegroup tc ON tc.cachegroup = c.name
 WHERE
   s.cdn_id = (SELECT cdn_id FROM deliveryservice WHERE id = $1)
   AND tc.topology = $2
+  AND c.type != (SELECT id FROM type WHERE name = '` + 
tc.CacheGroupOriginTypeName + `')
 GROUP BY s.id, s.cdn_id, c.name
 `
        rows, err := tx.Query(q, dsID, topology)
diff --git a/traffic_ops/traffic_ops_golang/topology/topologies.go 
b/traffic_ops/traffic_ops_golang/topology/topologies.go
index 383a689..bf77b01 100644
--- a/traffic_ops/traffic_ops_golang/topology/topologies.go
+++ b/traffic_ops/traffic_ops_golang/topology/topologies.go
@@ -328,7 +328,6 @@ func (topology TOTopology) validateDSRequiredCapabilities() 
error {
        for cdn := range cdnMap {
                CDNs = append(CDNs, cdn)
        }
-       // language=sql
        q := `
 SELECT
   s.id,
@@ -341,6 +340,7 @@ JOIN cachegroup c ON c.id = s.cachegroup
 WHERE
   c.name = ANY($1)
   AND s.cdn_id = ANY($2)
+  AND c.type != (SELECT id FROM type WHERE name = '` + 
tc.CacheGroupOriginTypeName + `')
 GROUP BY s.id, s.cdn_id, c.name
 `
        rows, err := tx.Query(q, pq.Array(cachegroups), pq.Array(CDNs))

Reply via email to