henry3260 commented on code in PR #75016:
URL: https://github.com/apache/airflow/pull/75016#discussion_r4311960911
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -444,16 +444,24 @@ def create_pod(self, pod: V1Pod) -> V1Pod:
return self.run_pod_async(pod)
async def watch_pod_events(self, pod: V1Pod, check_interval: float = 10)
-> None:
- """Read pod events and write into log."""
+ """
+ Read pod events and write into log.
+
+ Best-effort: an API failure logs one warning and stops the watch.
+ """
resource_version = None
seen_events: set[str] = set()
while not self.stop_watching_events:
- events = self.read_pod_events(pod, resource_version)
- if events.metadata and events.metadata.resource_version:
- resource_version = events.metadata.resource_version
- for event in events.items:
- log_pod_event(self, event, seen_events)
- resource_version = event.metadata.resource_version
+ try:
+ events = self.read_pod_events(pod, resource_version)
+ if events.metadata and events.metadata.resource_version:
+ resource_version = events.metadata.resource_version
+ for event in events.items:
+ log_pod_event(self, event, seen_events)
+ resource_version = event.metadata.resource_version
+ except Exception as e:
Review Comment:
nit: the bare `except Exception` is wider than "an API failure". A bug
inside `log_pod_event` (say `event.metadata` is None) is flattened into the
same one-line warning, and because `self.log.warning("...: %s", e)` carries no
traceback there is nothing left to debug with. A single non-API transient
error also gives up on this pod's events permanently instead of retrying on
the next poll.
Consider narrowing to `except (ApiException, HTTPError, KubernetesApiError)`,
or at least passing `exc_info=True`. Same handler at
`utils/pod_manager.py:1221` in `AsyncPodManager` — worth changing both.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]