This is an automated email from the ASF dual-hosted git repository. rshah pushed a commit to branch 8.0.1 in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 89450b34357ad30fe386d2cf76e69352927b5b53 Author: Rima Shah <[email protected]> AuthorDate: Wed Mar 6 12:35:18 2024 -0700 Fix incorrect display of delivery services for an ORG server (#7957) Co-authored-by: Chatterjee, Srijeet <[email protected]> (cherry picked from commit 08390960654ae569b1ca1b2b95e758865f79a5fe) --- CHANGELOG.md | 7 ++++++- .../api/v3/servers_id_deliveryservices_test.go | 3 +-- .../api/v4/servers_id_deliveryservices_test.go | 3 +-- .../api/v5/servers_id_deliveryservices_test.go | 3 +-- .../deliveryservice/servers/servers.go | 24 +++++++++++++++------- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0559f1e90a..29099eeb41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. 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 4db6fe2016..6eaedd3d04 100644 --- a/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go +++ b/traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go @@ -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) { queryDataString := `, cg.name as cachegroup, @@ -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 @@ -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 {
