apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: del upstream but not del route, request the route, return 500

Open idbeta opened this issue 6 years ago • 8 comments

  • Why do you submit this issue?
  • [ ] Question or discussion
  • [x] Bug
  • [ ] Requirements
  • [ ] Feature or performance improvement
  • [ ] Other

Bug

  • Which version of Apache APISIX Dashboard, OS, and Browser? APISIX 2.0 + APISIX-dashbaord 2.0

step1: create upstream step2: create route, and chose upstream created by step1 step3: del the step1's upstream from dashboard's upstream page step4: request the route, return 500

I think step3 should be limited.

idbeta avatar Nov 08 '20 13:11 idbeta

that is a bug we know already, we can fix it later

membphis avatar Nov 09 '20 04:11 membphis

for this issue, we should print a friendly error message, help the user to know the reason

membphis avatar Nov 09 '20 04:11 membphis

@membphis it's the same bug I found by e2e test

nic-chen avatar Nov 09 '20 12:11 nic-chen

ok, got it. we can fix it in 2.1, low priority

membphis avatar Nov 09 '20 13:11 membphis

here is test case

{
	caseDesc:     "delete upstream - being used by route 1",
	Object:       MangerApiExpect(t),
	Method:       http.MethodDelete,
	Path:         "/apisix/admin/upstreams/1",
	Headers:      map[string]string{"Authorization": token},
	ExpectStatus: http.StatusBadRequest,
},

idbeta avatar Nov 27 '20 10:11 idbeta

Here is an example, the APISIX will return 500 if failed to load the upstream by id upstream_id, and will generate a error log.

curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/index.html",
    "plugins": {
        "limit-count": {
            "count": 2,
            "time_window": 60,
            "rejected_code": 503,
            "key": "remote_addr"
        }
    },
    "upstream_id": "no_exist_id"
}'

For this case, the APISIX can return 502 and write a WARN error log, should be enough

membphis avatar Dec 14 '20 09:12 membphis

@spacewander what do you think?

membphis avatar Dec 14 '20 09:12 membphis

Yes, for DP, return 502 is enough.

spacewander avatar Dec 14 '20 09:12 spacewander