Skip to content

Commit ef764fe

Browse files
authored
fix: handle httpx.ReadError in k8s watcher (#1179)
1 parent 9f12418 commit ef764fe

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • components/renku_data_services/k8s/watcher

components/renku_data_services/k8s/watcher/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from collections.abc import Awaitable, Callable
99
from datetime import datetime, timedelta
1010

11+
import httpcore
12+
import httpx
13+
1114
from renku_data_services.app_config import logging
1215
from renku_data_services.base_models.core import APIUser, InternalServiceAdmin, ServiceAdminId
1316
from renku_data_services.base_models.metrics import MetricsService
@@ -118,6 +121,13 @@ async def __watch_kind(self, kind: GVK, client: K8sClusterClient) -> None:
118121
await self.__handler(cluster.with_api_object(obj), event_type)
119122
except ValueError:
120123
pass
124+
except (httpx.ReadError, httpcore.ReadError):
125+
# This can happen occasionally - most likely means that the k8s cluster stopped the connection
126+
logger.warning(
127+
"Encountered HTTP ReadError, will try to immediately restart event "
128+
f"watch for cluster {cluster_id} and kind {kind}."
129+
)
130+
continue
121131
except Exception as e:
122132
logger.error(f"watch loop failed for {kind} in cluster {cluster_id}", exc_info=e)
123133

0 commit comments

Comments
 (0)