Skip to content

Commit

Permalink
Fix incorrect display of delivery services for an ORG server (#7957)
Browse files Browse the repository at this point in the history
Co-authored-by: Chatterjee, Srijeet <srijeet_chatterjee@comcast.com>

(cherry picked from commit 0839096)
  • Loading branch information
rimashah25 committed Mar 6, 2024
1 parent 2190789 commit 89450b3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [8.0.0] - 2024-01-24
## [8.0.1] - 2024-03-06
### Fixed
- [#7957](https://github.com/apache/trafficcontrol/pull/7957) *Traffic Ops* Fix the incorrect display of delivery services assigned to ORG servers.
- [#7929](https://github.com/apache/trafficcontrol/pull/7929) *Traffic Ops* Ensure read-only role can perform only GET requests.

## [8.0.0] - 2024-01-30
### Added
- [#7896](https://github.com/apache/trafficcontrol/pull/7896) *ATC Build system*: Count commits since the last release, not commits.
- [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control Health Client*: Added peer monitor flag while using `strategies.yaml`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ func TestServersIDDeliveryServices(t *testing.T) {
GetServerID(t, "denver-mso-org-01")(),
[]int{
GetDeliveryServiceId(t, "ds-top")(),
GetDeliveryServiceId(t, "ds-top-req-cap2")(),
},
2)),
1)),
},
"CONFLICT when SERVER NOT IN SAME CDN as DELIVERY SERVICE": {
EndpointID: GetServerID(t, "cdn2-test-edge"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ func TestServersIDDeliveryServices(t *testing.T) {
totest.GetServerID(t, TOSession, "denver-mso-org-01")(),
[]int{
totest.GetDeliveryServiceId(t, TOSession, "ds-top")(),
totest.GetDeliveryServiceId(t, TOSession, "ds-top-req-cap2")(),
},
2)),
1)),
},
"CONFLICT when SERVER NOT IN SAME CDN as DELIVERY SERVICE": {
EndpointID: totest.GetServerID(t, TOSession, "cdn2-test-edge"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ func TestServersIDDeliveryServices(t *testing.T) {
GetServerID(t, "denver-mso-org-01")(),
[]int{
GetDeliveryServiceId(t, "ds-top")(),
GetDeliveryServiceId(t, "ds-top-req-cap2")(),
},
2)),
1)),
},
"CONFLICT when SERVER NOT IN SAME CDN as DELIVERY SERVICE": {
EndpointID: GetServerID(t, "cdn2-test-edge"),
Expand Down
24 changes: 17 additions & 7 deletions traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ func GetReadAssigned(w http.ResponseWriter, r *http.Request) {
api.WriteAlertsObj(w, r, http.StatusOK, alerts, servers)
}

func read(inf *api.APIInfo) ([]tc.DSServerV4, error) {
func read(inf *api.Info) ([]tc.DSServerV4, error) {

Check failure on line 770 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View workflow job for this annotation

GitHub Actions / go-vet

undefined: api.Info

Check failure on line 770 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View workflow job for this annotation

GitHub Actions / go-vet

undefined: api.Info
queryDataString :=
`,
cg.name as cachegroup,
Expand Down Expand Up @@ -944,9 +944,20 @@ func (dss *TODSSDeliveryService) Read(h http.Header, useIMS bool) ([]interface{}
where = "WHERE "
}

where += `
serverID, _ := strconv.Atoi(params["id"])
serverInfo, exists, err := dbhelpers.GetServerInfo(serverID, tx)
if err != nil {
return nil, nil, err, http.StatusInternalServerError, nil
}
if !exists {
return nil, fmt.Errorf("server with ID %d doesn't exist", serverID), nil, http.StatusNotFound, nil
}
if serverInfo.Type == tc.OriginTypeName {
where += `ds.id in (SELECT deliveryservice FROM deliveryservice_server WHERE server = :server)`
} else {
where += `
(ds.id in (
SELECT deliveryService FROM deliveryservice_server WHERE server = :server
SELECT deliveryservice FROM deliveryservice_server WHERE server = :server
) OR ds.id in (
SELECT d.id FROM deliveryservice d
JOIN cdn c ON d.cdn_id = c.id
Expand All @@ -959,17 +970,16 @@ func (dss *TODSSDeliveryService) Read(h http.Header, useIMS bool) ([]interface{}
)))
AND d.cdn_id = (SELECT cdn_id FROM server WHERE id = :server)))
AND
((
(SELECT (t.name = 'ORG') FROM type t JOIN server s ON s.type = t.id WHERE s.id = :server)
OR
((
(SELECT COALESCE(ARRAY_AGG(ssc.server_capability), '{}')
FROM server_server_capability ssc
WHERE ssc."server" = :server)
@>
@>
(
SELECT COALESCE(ds.required_capabilities, '{}')
)))
`
}

tenantIDs, err := tenant.GetUserTenantIDListTx(tx, user.TenantID)
if err != nil {
Expand Down

0 comments on commit 89450b3

Please sign in to comment.