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 17:15:06 UTC

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

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



##########
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:
       Originally, I left this out of the where clause, but it included servers from other CDNs. That was unexpected, since I thought exactly what you thought. I'm not totally sure why, but this condition is necessary.




----------------------------------------------------------------
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