Added filter (host name or ID) to query API route: /servercheck#5545
Added filter (host name or ID) to query API route: /servercheck#5545ocket8888 merged 16 commits intoapache:masterfrom
Conversation
…servercheck table
fb3356a to
3122143
Compare
ocket8888
left a comment
There was a problem hiding this comment.
So I'm noticing two things. First of all, the two query parameters cannot be used at the same time; it results in no filtering:
GET /api/3.0/servercheck?name=mid-01&id=11 HTTP/1.1
User-Agent: python-requests/2.24.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: mojolicious=...HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin: *
Content-Encoding: gzip
Content-Type: application/json
Set-Cookie: mojolicious=...; Path=/; Expires=Wed, 24 Feb 2021 00:22:40 GMT; Max-Age=3600; HttpOnly
Vary: Accept-Encoding
X-Server-Name: traffic_ops_golang/
Date: Tue, 23 Feb 2021 23:22:40 GMT
Content-Length: 217
{
"response": [
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 11,
"hostName": "edge",
"revalPending": false,
"profile": "ATS_EDGE_TIER_CACHE",
"type": "EDGE",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Mid-01",
"id": 12,
"hostName": "mid-01",
"revalPending": false,
"profile": "ATS_MID_TIER_CACHE",
"type": "MID",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Mid-02",
"id": 6,
"hostName": "mid-02",
"revalPending": false,
"profile": "ATS_MID_TIER_CACHE",
"type": "MID",
"updPending": false
}
]
}If this is intended behavior and the two cannot both exist in the request, that should be documented, and ideally it'd return a warning-level alert indicating why filtering wasn't performed. Otherwise, if the intent is that they can both be used, then filtering when the id and hostname refer to the same server should result in an output length of exactly one, and if they do not refer to the same server, then it should return an empty array because nothing matches.
Secondly, if I give it a query parameter that it doesn't recognize or requires others, I can get back a response that includes non-cache servers:
GET /api/3.0/servercheck?page=1 HTTP/1.1
User-Agent: python-requests/2.24.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: mojolicious=...HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin: *
Content-Encoding: gzip
Content-Type: application/json
Set-Cookie: mojolicious=...
Vary: Accept-Encoding
X-Server-Name: traffic_ops_golang/
Date: Tue, 23 Feb 2021 23:27:46 GMT
Content-Length: 477
{
"response": [
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 3,
"hostName": "db",
"revalPending": false,
"profile": "TRAFFIC_OPS_DB",
"type": "TRAFFIC_OPS_DB",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 5,
"hostName": "dns",
"revalPending": false,
"profile": "BIND_ALL",
"type": "BIND",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 11,
"hostName": "edge",
"revalPending": false,
"profile": "ATS_EDGE_TIER_CACHE",
"type": "EDGE",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 9,
"hostName": "enroller",
"revalPending": false,
"profile": "ENROLLER_ALL",
"type": "ENROLLER",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 7,
"hostName": "influxdb",
"revalPending": false,
"profile": "INFLUXDB",
"type": "INFLUXDB",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Mid-01",
"id": 12,
"hostName": "mid-01",
"revalPending": false,
"profile": "ATS_MID_TIER_CACHE",
"type": "MID",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Mid-02",
"id": 6,
"hostName": "mid-02",
"revalPending": false,
"profile": "ATS_MID_TIER_CACHE",
"type": "MID",
"updPending": false
},
{
"adminState": "REPORTED",
"cacheGroup": "CDN_in_a_Box_Origin",
"id": 8,
"hostName": "origin",
"revalPending": false,
"profile": "ORG_MSO",
"type": "ORG",
"updPending": true
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 2,
"hostName": "trafficmonitor",
"revalPending": false,
"profile": "RASCAL-Traffic_Monitor",
"type": "RASCAL",
"updPending": true
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 13,
"hostName": "trafficops",
"revalPending": false,
"profile": "TRAFFIC_OPS",
"type": "TRAFFIC_OPS",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 4,
"hostName": "trafficportal",
"revalPending": false,
"profile": "TRAFFIC_PORTAL",
"type": "TRAFFIC_PORTAL",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 10,
"hostName": "trafficrouter",
"revalPending": false,
"profile": "CCR_CIAB",
"type": "CCR",
"updPending": true
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 1,
"hostName": "trafficstats",
"revalPending": false,
"profile": "TRAFFIC_STATS",
"type": "TRAFFIC_STATS",
"updPending": false
},
{
"adminState": "ONLINE",
"cacheGroup": "CDN_in_a_Box_Edge",
"id": 14,
"hostName": "trafficvault",
"revalPending": false,
"profile": "RIAK_ALL",
"type": "RIAK",
"updPending": false
}
]
}…ement/git-3577 � Conflicts: � traffic_ops/v4-client/servercheck.go
ocket8888
left a comment
There was a problem hiding this comment.
It all seems to be working rather consistently now.
What does this PR (Pull Request) do?
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
curl GET for the following calls:
Get all servers: /api/4.0/servercheck or using unknown query param


Get server with a specific param id: /api/4.0/servercheck?id=12
Using both query param

Using server names and id that don't match in the DB.

If this is a bug fix, what versions of Traffic Control are affected?
The following criteria are ALL met by this PR
Additional Information