kubespawner
kubespawner copied to clipboard
KubeIngressProxy.add_route does not catch 404 exception
Bug description
When I upgrade from 1.1.0 to 4.2.0 for using networking.k8s.io/v1 ingress, the jupyterhub can not startup successfully. It seems that the reason is the k8s client switch from kubernetes to kubernetes-asyncio, but exception catching not follow, it still catch kubernetes client.rest.ApiException.
Expected behaviour
In old version, delete_if_exists works find
[I 2022-09-24 07:03:28.010 JupyterHub proxy:347] Checking routes [I 2022-09-24 07:03:28.010 JupyterHub proxy:432] Adding route for Hub: /jupyterhub/ => http://jupyterhub-hub.jupyterhub-test:8081 [W 2022-09-24 07:03:28.022 JupyterHub proxy:174] Could not delete endpoint/jupyter--2fjupyterhub-2f-route: does not exist
Actual behaviour
The error come up while jupyterhub startup adding route:
[I 2022-09-24 06:57:45.072 JupyterHub proxy:347] Checking routes [I 2022-09-24 06:57:45.073 JupyterHub proxy:432] Adding route for Hub: /jupyterhub/ => http://jupyterhub-hub.jupyterhub-test:8081 [I 2022-09-24 06:57:45.073 JupyterHub reflector:274] watching for ingresses with label selector='component=singleuser-server,hub.jupyter.org/proxy-route=true' in namespace jupyterhub-test [E 2022-09-24 06:57:45.088 JupyterHub app:2989] Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/jupyterhub/app.py", line 2987, in launch_instance_async await self.start() File "/usr/local/lib/python3.8/dist-packages/jupyterhub/app.py", line 2852, in start await self.proxy.check_routes(self.users, self._service_map) File "/usr/local/lib/python3.8/dist-packages/jupyterhub/proxy.py", line 70, in locked_method return await method(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/jupyterhub/proxy.py", line 426, in check_routes await asyncio.gather(*futures) File "/usr/local/lib/python3.8/dist-packages/kubespawner/proxy.py", line 282, in add_route delete_endpoint = await self.core_api.delete_namespaced_endpoints( File "/usr/local/lib/python3.8/dist-packages/kubernetes_asyncio/client/api_client.py", line 192, in __call_api raise e File "/usr/local/lib/python3.8/dist-packages/kubernetes_asyncio/client/api_client.py", line 185, in __call_api response_data = await self.request( File "/usr/local/lib/python3.8/dist-packages/kubernetes_asyncio/client/rest.py", line 220, in DELETE return (await self.request("DELETE", url, File "/usr/local/lib/python3.8/dist-packages/kubernetes_asyncio/client/rest.py", line 187, in request raise ApiException(http_resp=r) kubernetes_asyncio.client.exceptions.ApiException: (404) Reason: Not Found HTTP response headers: <CIMultiDictProxy('Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'e5de13be-c33d-42b2-81fc-dfe70af0138d', 'X-Kubernetes-Pf-Prioritylevel-Uid': 'dbd2c24e-667b-41af-a77d-a9f454ea9c3e', 'Date': 'Sat, 24 Sep 2022 06:57:45 GMT', 'Content-Length': '238')> HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"endpoints "jupyter--2fjupyterhub-2f-route" not found","reason":"NotFound","details":{"name":"jupyter--2fjupyterhub-2f-route","kind":"endpoints"},"code":404}
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
Fix: #646