mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 23:13:00 +00:00
Fail suspected API requests with 404, not 503
Non-running user servers making requests is a fairly common occurance - user servers get culled while their browser tabs are left open. So we now have a background level of 503s responses on the hub *all* the time, making it very difficult to detect *real* 503s, which should ideally be closely monitored and alerted on. I *think* 404 is a more appropriate response, as the resource (API) being requested is no longer present.
This commit is contained in:
@@ -1349,7 +1349,7 @@ class UserUrlHandler(BaseHandler):
|
||||
self.log.warning(
|
||||
"Failing suspected API request to not-running server: %s", self.request.path
|
||||
)
|
||||
self.set_status(503)
|
||||
self.set_status(404)
|
||||
self.set_header("Content-Type", "application/json")
|
||||
|
||||
spawn_url = urlparse(self.request.full_url())._replace(query="")
|
||||
|
@@ -1001,7 +1001,7 @@ async def test_token_page(app):
|
||||
async def test_server_not_running_api_request(app):
|
||||
cookies = await app.login_user("bees")
|
||||
r = await get_page("user/bees/api/status", app, hub=False, cookies=cookies)
|
||||
assert r.status_code == 503
|
||||
assert r.status_code == 404
|
||||
assert r.headers["content-type"] == "application/json"
|
||||
message = r.json()['message']
|
||||
assert ujoin(app.base_url, "hub/spawn/bees") in message
|
||||
|
Reference in New Issue
Block a user