Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Conversation

@jagan-parthiban
Copy link
Contributor

@jagan-parthiban jagan-parthiban commented May 15, 2023

Closes: #7519


Which Traffic Control components are affected by this PR?

  • Documentation
  • Traffic Ops

What is the best way to verify this PR?

Get request to Traffic Ops API /servers/{id}/deliveryservices endpoint should provide both DS that are directly assigned and that are inherited from the topology.

curl --request GET \
  --url https://localhost:8443/api/4.1/servers/{id}/deliveryservices

If this is a bugfix, which Traffic Control versions contained the bug?

  • 7.0.1

PR submission checklist

@jagan-parthiban jagan-parthiban force-pushed the bug/deliveryservice-endpoint branch from 4ce1bf5 to 6a7e0aa Compare May 19, 2023 03:34
@jagan-parthiban jagan-parthiban marked this pull request as ready for review May 19, 2023 17:57
@codecov
Copy link

codecov bot commented May 22, 2023

Codecov Report

Merging #7520 (c85c093) into master (daa7d21) will decrease coverage by 2.88%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##             master    #7520      +/-   ##
============================================
- Coverage     33.31%   30.44%   -2.88%     
  Complexity       98       98              
============================================
  Files           499      792     +293     
  Lines         50832    82868   +32036     
  Branches        851      885      +34     
============================================
+ Hits          16937    25227    +8290     
- Misses        32655    55527   +22872     
- Partials       1240     2114     +874     
Flag Coverage Δ
golib_unit 48.56% <ø> (?)
grove_unit 4.60% <ø> (?)
t3c_unit 5.32% <ø> (?)
traffic_monitor_unit 21.35% <ø> (?)
traffic_ops_integration 69.42% <ø> (ø)
traffic_ops_unit 23.42% <0.00%> (-0.02%) ⬇️
traffic_portal_v2 74.93% <ø> (-0.06%) ⬇️
traffic_stats_unit 10.14% <ø> (?)
unit_tests 27.54% <0.00%> (-1.30%) ⬇️
v3 57.79% <ø> (ø)
v4 79.18% <ø> (ø)
v5 78.63% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ffic_ops_golang/deliveryservice/servers/servers.go 32.12% <0.00%> (-0.49%) ⬇️

... and 306 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zrhoffman zrhoffman added bug something isn't working as intended Traffic Ops related to Traffic Ops labels May 23, 2023
@jagan-parthiban jagan-parthiban force-pushed the bug/deliveryservice-endpoint branch from a5dd2bc to bdd96b1 Compare May 28, 2023 13:38
Copy link
Member

@zrhoffman zrhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

Copy link
Member

@zrhoffman zrhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The V3 Delivery Service API tests fail:

--- FAIL: TestServersIDDeliveryServices (6.62s)
    --- FAIL: TestServersIDDeliveryServices/POST (0.13s)
        --- FAIL: TestServersIDDeliveryServices/POST/OK_when_VALID_request (0.03s)
            servers_id_deliveryservices_test.go:167: Not equal. Expected: 1 Actual: 2 Messages: Expected one Delivery Service returned Got: 2
        --- FAIL: TestServersIDDeliveryServices/POST/OK_when_ASSIGNING_ORIGIN_to_TOPOLOGY_BASED_DELIVERY_SERVICE (0.03s)
            servers_id_deliveryservices_test.go:167: Not equal. Expected: 1 Actual: 3 Messages: Expected one Delivery Service returned Got: 3
FAIL

Also, this PR needs to be rebased onto the master branch to get #7546, which will make CDN in a Box work again

@jagan-parthiban
Copy link
Contributor Author

Fixed V3 Integration tests that were failing.

@jagan-parthiban jagan-parthiban requested a review from zrhoffman June 2, 2023 11:16
}
where += "ds.id in (SELECT deliveryService FROM deliveryservice_server where server = :server)"

where += "ds.id in (SELECT deliveryService FROM deliveryservice_server WHERE server = :server) OR ds.id in (SELECT id FROM deliveryservice WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server ))))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, accomplishing this with JOINs for the

WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server )))

instead of subqueries would be possible, but there is probably not a performance difference, so keeping this structure is fine.

}
where += "ds.id in (SELECT deliveryService FROM deliveryservice_server where server = :server)"

where += "ds.id in (SELECT deliveryService FROM deliveryservice_server WHERE server = :server) OR ds.id in (SELECT id FROM deliveryservice WHERE topology in ( SELECT topology FROM topology_cachegroup WHERE cachegroup = ( SELECT name FROM cachegroup WHERE id = ( SELECT cachegroup FROM server WHERE id = :server ))))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a long line for a query fragment. How about reformatting it as a multiline string like this?

	where += `
ds.id in (
	SELECT deliveryService FROM deliveryservice_server WHERE server = :server
) OR ds.id in (
	SELECT id FROM deliveryservice
	WHERE topology in (
		SELECT topology FROM topology_cachegroup
		WHERE cachegroup = (
			SELECT name FROM cachegroup
			WHERE id = (
				SELECT cachegroup FROM server WHERE id = :server
			))))
`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed It. Thanks

Comment on lines 900 to 910
ds.id in (
SELECT deliveryService FROM deliveryservice_server WHERE server = :server
) OR ds.id in (
SELECT id FROM deliveryservice
WHERE topology in (
SELECT topology FROM topology_cachegroup
WHERE cachegroup = (
SELECT name FROM cachegroup
WHERE id = (
SELECT cachegroup FROM server WHERE id = :server
))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queries should not be indented like the rest of the function, because if you look at the complete, assembled query that Traffic Ops logs, that indentation does not make sense.

So, the query fragment should be unindented by 2 tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

Copy link
Member

@zrhoffman zrhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! I'll merge when the GHAs pass.

@zrhoffman zrhoffman merged commit fffe8a3 into apache:master Jun 2, 2023
@jagan-parthiban jagan-parthiban deleted the bug/deliveryservice-endpoint branch June 8, 2023 10:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug something isn't working as intended Traffic Ops related to Traffic Ops

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TO API /servers/{id}/deliveryservices endpoint not responding with all DS's on cache

3 participants