avoid raising on 404 deleting proxy route

deleting a route that doesn't exist should only warn, not error
This commit is contained in:
Min RK
2018-01-31 11:04:06 +01:00
parent dde7b5ea68
commit c688e9ebad

View File

@@ -24,7 +24,7 @@ from subprocess import Popen
from urllib.parse import quote
from tornado import gen
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
from tornado.httpclient import AsyncHTTPClient, HTTPRequest, HTTPError
from tornado.ioloop import PeriodicCallback
@@ -576,7 +576,16 @@ class ConfigurableHTTPProxy(Proxy):
def delete_route(self, routespec):
path = self._routespec_to_chp_path(routespec)
try:
return self.api_request(path, method='DELETE')
except HTTPError as e:
if e.status_code == 404:
# Warn about 404s because something might be wrong
# but don't raise because the route is gone,
# which is the goal.
self.log.warning("Route %s already deleted", routespec)
else:
raise
def _reformat_routespec(self, routespec, chp_data):
"""Reformat CHP data format to JupyterHub's proxy API."""