mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 15:33:02 +00:00
Use 424 rather than 404 to indicate non-running server
404 is also used to identify that a particular resource (like a kernel or terminal) is not present, maybe because it is deleted. That comes from the notebook server, while here we are responding from JupyterHub. Saying that the user server they are trying to request the resource (kernel, etc) from does not exist seems right.
This commit is contained in:
@@ -1330,7 +1330,7 @@ class UserUrlHandler(BaseHandler):
|
|||||||
|
|
||||||
**Changed Behavior as of 1.0** This handler no longer triggers a spawn. Instead, it checks if:
|
**Changed Behavior as of 1.0** This handler no longer triggers a spawn. Instead, it checks if:
|
||||||
|
|
||||||
1. server is not active, serve page prompting for spawn (status: 503)
|
1. server is not active, serve page prompting for spawn (status: 424)
|
||||||
2. server is ready (This shouldn't happen! Proxy isn't updated yet. Wait a bit and redirect.)
|
2. server is ready (This shouldn't happen! Proxy isn't updated yet. Wait a bit and redirect.)
|
||||||
3. server is active, redirect to /hub/spawn-pending to monitor launch progress
|
3. server is active, redirect to /hub/spawn-pending to monitor launch progress
|
||||||
(will redirect back when finished)
|
(will redirect back when finished)
|
||||||
@@ -1349,7 +1349,11 @@ class UserUrlHandler(BaseHandler):
|
|||||||
self.log.warning(
|
self.log.warning(
|
||||||
"Failing suspected API request to not-running server: %s", self.request.path
|
"Failing suspected API request to not-running server: %s", self.request.path
|
||||||
)
|
)
|
||||||
self.set_status(404)
|
|
||||||
|
# If we got here, the server is not running. To differentiate
|
||||||
|
# that the *server* itself is not running, rather than just the particular
|
||||||
|
# resource *in* the server is not found, we return a 424 instead of a 404.
|
||||||
|
self.set_status(424)
|
||||||
self.set_header("Content-Type", "application/json")
|
self.set_header("Content-Type", "application/json")
|
||||||
|
|
||||||
spawn_url = urlparse(self.request.full_url())._replace(query="")
|
spawn_url = urlparse(self.request.full_url())._replace(query="")
|
||||||
@@ -1514,15 +1518,14 @@ class UserUrlHandler(BaseHandler):
|
|||||||
self.redirect(pending_url, status=303)
|
self.redirect(pending_url, status=303)
|
||||||
return
|
return
|
||||||
|
|
||||||
# if we got here, the server is not running
|
# If we got here, the server is not running. To differentiate
|
||||||
# serve a page prompting for spawn and 503 error
|
# that the *server* itself is not running, rather than just the particular
|
||||||
# visiting /user/:name no longer triggers implicit spawn
|
# page *in* the server is not found, we return a 424 instead of a 404.
|
||||||
# without explicit user action
|
|
||||||
spawn_url = url_concat(
|
spawn_url = url_concat(
|
||||||
url_path_join(self.hub.base_url, "spawn", user.escaped_name, server_name),
|
url_path_join(self.hub.base_url, "spawn", user.escaped_name, server_name),
|
||||||
{"next": self.request.uri},
|
{"next": self.request.uri},
|
||||||
)
|
)
|
||||||
self.set_status(503)
|
self.set_status(424)
|
||||||
|
|
||||||
auth_state = await user.get_auth_state()
|
auth_state = await user.get_auth_state()
|
||||||
html = await self.render_template(
|
html = await self.render_template(
|
||||||
|
Reference in New Issue
Block a user