cbranch
February 20, 2020, 9:09pm
1
The documentation for Target Object includes this paragraph:
Because the upstream maintains a history of target changes, the targets cannot be deleted or modified. To disable a target, post a new one with weight=0; alternatively, use the DELETE convenience method to accomplish the same.
Is this still accurate for 1.4.2 and later? I tried the following:
Create upstream
Create target for the upstream
Verify the target exists via the API and also via a database query (select * from targets)
Delete the target
After these steps, the database table is empty (select * from targets). Also, the following request returns an empty response:
http://localhost:8001/upstreams/{upstream_id}/targets/all
hbagdi
February 20, 2020, 11:15pm
2
@Tieske Something seems wrong here…
Tieske
February 21, 2020, 3:45pm
3
This is on Kong 1.4.2
/kong # http :8001/upstreams name=tieske
/kong # http :8001/upstreams/tieske/targets target=localhost:8000
/kong # http :8001/upstreams/tieske/targets
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 192
Content-Type: application/json; charset=utf-8
Date: Fri, 21 Feb 2020 15:41:48 GMT
Server: kong/1.4.2
X-Kong-Admin-Latency: 3
{
"data": [
{
"created_at": 1582299697.327,
"id": "b3832396-fa16-42a5-9b95-96280b87d1d7",
"target": "localhost:8000",
"upstream": {
"id": "7c3cdd44-e753-4a70-aebd-dc62a1c2e28e"
},
"weight": 100
}
],
"next": null
}
/kong # http :8001/upstreams/tieske/targets/all
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 204
Content-Type: application/json; charset=utf-8
Date: Fri, 21 Feb 2020 15:41:54 GMT
Server: kong/1.4.2
X-Kong-Admin-Latency: 8
{
"data": [
{
"created_at": 1582299697.327,
"id": "b3832396-fa16-42a5-9b95-96280b87d1d7",
"tags": null,
"target": "localhost:8000",
"upstream": {
"id": "7c3cdd44-e753-4a70-aebd-dc62a1c2e28e"
},
"weight": 100
}
],
"next": null
}
/kong # http -f :8001/upstreams/tieske/targets target=localhost:8000 weight=0
/kong # http :8001/upstreams/tieske/targets
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 23
Content-Type: application/json; charset=utf-8
Date: Fri, 21 Feb 2020 15:42:23 GMT
Server: kong/1.4.2
X-Kong-Admin-Latency: 2
{
"data": [],
"next": null
}
/kong # http :8001/upstreams/tieske/targets/all
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 23
Content-Type: application/json; charset=utf-8
Date: Fri, 21 Feb 2020 15:42:28 GMT
Server: kong/1.4.2
X-Kong-Admin-Latency: 6
{
"data": [],
"next": null
}
/kong #
Tieske
February 21, 2020, 3:48pm
4
also tested on 2.0.1, exact same result
Tieske
February 21, 2020, 3:54pm
5
1 Like