TykTechnologies / tyk-operator

Tyk Operator for Kubernetes
https://tyk.io
Other
198 stars 40 forks source link

bug: deleting all apis in the gateway should return 404 not found. #148

Closed asoorm closed 4 years ago

asoorm commented 4 years ago

This looks like a Gateway bug, however after investigation & resolution, we may need to remove the workaround in the tests.

This occurs with Tyk Pro, not Tyk CE. And the control port needs to be different to the proxy port.

If I create an API - e.g. httpbin, then delete it - I expected to get back a 404 not found when requesting the API. Rather, the gateway seems to stop listening on the port entirely.

Maybe this is desired behaviour - however it seems that Tyk CE acts differently. returning a 404 not found.

$ kubectl port-forward -n tykpro-control-plane svc/gw 8000:8000
E1102 09:43:14.530780   34478 portforward.go:400] an error occurred forwarding 8000 -> 8000: error forwarding port 8000 to pod e441c00617758a1233fff01b7d93fa39339eec1fcaef508df85ebf744c4dc404, uid : exit status 1: 2020/11/02 09:43:14 socat[8642] E connect(5, AF=2 127.0.0.1:8000, 16): Connection refused

https://github.com/TykTechnologies/tyk-operator/blob/master/bdd/godogs_test.go#L128-L136

$ curl localhost:8000/httpbin/get
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip", 
    "Host": "httpbin.default.svc:8000", 
    "User-Agent": "curl/7.71.1"
  }, 
  "origin": "127.0.0.1", 
  "url": "http://httpbin.default.svc:8000/get"
}
$ k delete tykapis httpbin
apidefinition.tyk.tyk.io "httpbin" deleted
$ curl localhost:8000/httpbin/get
curl: (52) Empty reply from server
asoorm commented 4 years ago

This looks like intended functionality:

time="Nov 02 13:28:37" level=info msg="Found unused listener at port 8000, shutting down" prefix=main
asoorm commented 4 years ago

Closing because it is intended functionality with the Gateway