diff --git a/CHANGELOG.md b/CHANGELOG.md index 06da5e9e70..caded33850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 +- [#7957](https://github.com/apache/trafficcontrol/pull/7957) *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 @@ -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. diff --git a/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go b/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go index 9dd2f45d03..93c5b376d5 100644 --- a/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go +++ b/traffic_ops/testing/api/v3/servers_id_deliveryservices_test.go @@ -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"), diff --git a/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go b/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go index 87b7e45060..9949eb2a31 100644 --- a/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go +++ b/traffic_ops/testing/api/v4/servers_id_deliveryservices_test.go @@ -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"), diff --git a/traffic_ops/testing/api/v5/servers_id_deliveryservices_test.go b/traffic_ops/testing/api/v5/servers_id_deliveryservices_test.go index 2cae5f3018..4b6f10e3bf 100644 --- a/traffic_ops/testing/api/v5/servers_id_deliveryservices_test.go +++ b/traffic_ops/testing/api/v5/servers_id_deliveryservices_test.go @@ -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"), diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go index 1b14e0a930..6eaedd3d04 100644 --- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go +++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go @@ -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 @@ -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 {