You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/10/05 23:23:47 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #5093: Validate addition of DS required capabilities w.r.t its topology

zrhoffman commented on a change in pull request #5093:
URL: https://github.com/apache/trafficcontrol/pull/5093#discussion_r499924098



##########
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:
       Tests seem to pass for me with `s.cdn_id = d.cdn_id`




----------------------------------------------------------------
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:
users@infra.apache.org