Skip to content

Commit

Permalink
Fix incorrect display of delivery services for an ORG server
Browse files Browse the repository at this point in the history
add changelog
code review
---------
Co-authored-by: Srijeet Chatterjee <[email protected]>
  • Loading branch information
srijeet0406 authored and rimashah25 committed Mar 6, 2024
1 parent dc995a9 commit 63e6cd9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Updated Go version to 1.22.0

### Fixed
- [#7956](https://github.com/apache/trafficcontrol/pull/7956) *Traffic Ops* Fix the incorrect display of delivery services assigned to ORG servers.
- [#7917](https://github.com/apache/trafficcontrol/pull/7917) *Traffic Ops* Removed `Alerts` field from struct `ProfileExportResponse`.
- [#7918](https://github.com/apache/trafficcontrol/pull/7918) *Traffic Portal* Fixed topology link under DS-Servers tables page
- [#7846](https://github.com/apache/trafficcontrol/pull/7846) *Traffic Portal* Increase State character limit
Expand All @@ -25,7 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7832](https://github.com/apache/trafficcontrol/pull/7832) *t3c* Removed Perl dependency
- [#7841](https://github.com/apache/trafficcontrol/pull/7841) *Postinstall* Removed Perl implementation and Python 2.x support

## [8.0.0] - 2023-09-20
## [8.0.0] - 2024-01-30
### Added
- [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control Health Client*: Added peer monitor flag while using `strategies.yaml`.
- [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic Portal*: Added Scope Query Param to SSO login.
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 @@ -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 @@ -960,16 +971,15 @@ 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(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 63e6cd9

Please sign in to comment.