rawlinp commented on a change in pull request #5307:
URL: https://github.com/apache/trafficcontrol/pull/5307#discussion_r527815228
##########
File path: traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go
##########
@@ -1009,3 +1010,49 @@ GROUP BY t.name, ds.topology
}
return dsType, reqCap, topology, true, nil
}
+
+// CheckOriginServerInCacheGroupTopology checks if a DS has ORG server and if
it does, to make sure the cachegroup is part of DS
+func CheckOriginServerInCacheGroupTopology(tx *sql.Tx, dsID int, dsTopology
string) (error, error, int) {
+ // get servers and respective cachegroup name that have ORG type in a
delivery service
+ q := `
+ SELECT s2.host_name, c.name
+ FROM server s2
+ INNER JOIN deliveryservice_server ds ON ds.server =
s2.id
+ inner join type t on t.id = s2.type
+ INNER JOIN cachegroup c ON c.id = s2.cachegroup
+ WHERE ds.deliveryservice=$1 and t.name='ORG'
+ GROUP BY s2.host_name, c.name
Review comment:
What is the error exactly? When I run this query without the group by, I
get no errors:
```
to_development=# SELECT s2.host_name, c.name
FROM server s2
INNER JOIN deliveryservice_server ds ON ds.server = s2.id
inner join type t on t.id = s2.type
INNER JOIN cachegroup c ON c.id = s2.cachegroup
WHERE ds.deliveryservice=10276 and t.name='ORG';
host_name | name
-----------+---------------------
cfg2 | multi-site-org-west
(1 row)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]