Error while deleting upstream

#1

Hi,

I have downloaded and installed Kong community 1.1.0 version and whenever I am trying to delete the upstream, it throws below error.

HTTP/1.1 400 Bad Request
{“message”:“an existing ‘targets’ entity references this ‘upstreams’ entity”,“name”:“foreign key violation”,“fields”:{"@referenced_by":“targets”},“code”:4}

Similar issue existed in previous community versions(1.0.3) . I saw that they have given a patch and resolved the issue in the GitHub Kong 1.0.3 source code but it still exists in Kong community 1.1.0 deb release.

Can anyone help and let me know how to fix it .

0 Likes

#2

I can’t seem to reproduce this using Kong 1.1.0 w\ postgres via docker-compose

export KONG_DOCKER_TAG=kong:1.1.0
docker-compose up -d

http POST localhost:8001/services name=service name=example-service url=http://mockbin.org

http POST localhost:8001/upstreams name=mockbin.org

http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org

http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Mon, 01 Apr 2019 15:22:56 GMT
Server: kong/1.0.3

http GET localhost:8001/upstreams/
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 23
Content-Type: application/json; charset=utf-8
Date: Mon, 01 Apr 2019 15:23:10 GMT
Server: kong/1.0.3

{
    "data": [],
    "next": null
}
0 Likes

#3

Thanks for the response. There seems to be some issue with the configurations. I restarted kong and it started working.

0 Likes

#4

Any details about the configurations you can provide to try and reproduce?

0 Likes

#5

I performed below steps:

  1. Installed Kong 1.0.3 which has this issue.

  2. Installed Kong 1.1 on top of Kong 1.0.3

  3. Ran kong migrations up

  4. Then until I restarted kong, I had the issue.

Thanks

0 Likes

#6

I can’t seem to reproduce it in 1.0.3 and I can’t reproduce it when I update a 1.0.3 install to a 1.1.1 installation

export KONG_DOCKER_TAG=kong:1.0.3
docker-compose up -d

http POST localhost:8001/services name=service name=example-service url=http://mockbin.org
http POST localhost:8001/upstreams name=mockbin.org
http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org
http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Wed, 03 Apr 2019 15:21:11 GMT
Server: kong/1.0.3

http POST localhost:8001/upstreams name=mockbin.org
http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org

export KONG_DOCKER_TAG=kong:1.1.1
docker-compose up -d

http localhost:8001/upstreams
http localhost:8001/upstreams/mockbin.org/targets
http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Wed, 03 Apr 2019 15:24:12 GMT
Server: kong/1.1.1
0 Likes

#7

Can you please try installing Kong via 1.0.3 deb file instead of docker.

Thanks

Atul

0 Likes

#8

The debian and docker assets are functionally identical as they’re built from the same code, installed into a temporary directory and then packages into a .deb / tag.gz.

I also haven’t seen similar bug reports to this. When Kong fails to delete the upstream is there anything relevant in Kong / postgres logs?

0 Likes