zrhoffman commented on a change in pull request #5093:
URL: https://github.com/apache/trafficcontrol/pull/5093#discussion_r499325438
##########
File path:
traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices_required_capabilities.go
##########
@@ -329,6 +340,72 @@ func (rc *RequiredCapability) checkServerCap() (error,
error, int) {
return nil, nil, http.StatusOK
}
+// 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,
requiredCapabilities []string) (error, error, int) {
+ q := `
+SELECT
+ s.id,
+ c.name,
+ ARRAY_REMOVE(ARRAY_AGG(ssc.server_capability ORDER BY
ssc.server_capability), NULL) AS capabilities
+FROM server s
+LEFT JOIN server_server_capability ssc ON ssc.server = s.id
+JOIN cachegroup c ON c.id = s.cachegroup
+JOIN topology_cachegroup tc ON tc.cachegroup = c.name
+JOIN deliveryservice d ON d.topology = tc.topology
+WHERE
+ d.id = $1
+ AND s.cdn_id = (SELECT cdn_id FROM deliveryservice WHERE id = $1)
Review comment:
Because we already have `d.id = $1`, comparing against the result of
this subquery produces the same result as filtering by `s.cdn_id = d.cdn_id`,
right?
----------------------------------------------------------------
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]