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/14 15:08:56 UTC

[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #5128: strips out servers in the wrong cdn if requesting servers for a ds

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



##########
File path: traffic_ops/traffic_ops_golang/server/servers.go
##########
@@ -782,12 +782,17 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 	usesMids := false
 	queryAddition := ""
 	dsHasRequiredCapabilities := false
+	var dsCDNName tc.CDNName
 	if dsIDStr, ok := params[`dsId`]; ok {
 		// don't allow query on ds outside user's tenant
 		dsID, err := strconv.Atoi(dsIDStr)
 		if err != nil {
 			return nil, 0, errors.New("dsId must be an integer"), nil, http.StatusNotFound, nil
 		}
+		_, dsCDNName, _, err = dbhelpers.GetDSNameAndCDNFromID(tx.Tx, dsID)
+		if err != nil {
+			return nil, 0, errors.New("ds not found"), nil, http.StatusNotFound, nil
+		}

Review comment:
       We should not need to check which CDN the delivery service is in. The query just needs to be adjusted to make sure the servers match the delivery service's CDN.

##########
File path: traffic_ops/traffic_ops_golang/server/servers.go
##########
@@ -976,8 +981,13 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 	}
 
 	returnable := make([]tc.ServerNullable, 0, len(ids))
+
 	for _, id := range ids {
 		server := servers[id]
+		// if requesting servers for a given ds, need to only include those in the same cdn
+		if len(dsCDNName) > 0 && string(dsCDNName) != *server.CDNName {
+			continue
+		}

Review comment:
       Is there a way to perform this check in the query itself?




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