Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect display of delivery services for an ORG server #7957

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
- [#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
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 @@
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 += `

Check warning on line 958 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View check run for this annotation

Codecov / codecov/patch

traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go#L947-L958

Added lines #L947 - L958 were not covered by tests
(ds.id in (
SELECT deliveryService FROM deliveryservice_server WHERE server = :server
SELECT deliveryservice FROM deliveryservice_server WHERE server = :server

Check warning on line 960 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View check run for this annotation

Codecov / codecov/patch

traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go#L960

Added line #L960 was not covered by tests
) 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 @@
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)

Check warning on line 976 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View check run for this annotation

Codecov / codecov/patch

traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go#L974-L976

Added lines #L974 - L976 were not covered by tests
@>
(
SELECT COALESCE(ds.required_capabilities, '{}')
)))
`
}

Check warning on line 982 in traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go

View check run for this annotation

Codecov / codecov/patch

traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go#L982

Added line #L982 was not covered by tests

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