cruseakshay commented on code in PR #60626:
URL: https://github.com/apache/airflow/pull/60626#discussion_r2707175341
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -811,13 +832,54 @@ def read_pod_events(self, pod: V1Pod, resource_version:
str | None = None) -> Co
raise KubernetesApiException(f"There was an error reading the
kubernetes API: {e}")
@generic_api_retry
- def read_pod(self, pod: V1Pod) -> V1Pod:
- """Read POD information."""
+ def read_pod(self, pod: V1Pod, *, phase_tracker: PodPhaseTracker | None =
None) -> V1Pod:
+ """
+ Read POD information.
+
+ :param pod: The pod object to read.
+ :param phase_tracker: Optional tracker to monitor pod lifecycle state.
+ When provided, enables state-aware retry behavior on 404 errors
+ to handle pod preemption during node bootstrap.
+ """
try:
- return self._client.read_namespaced_pod(pod.metadata.name,
pod.metadata.namespace)
+ result = self._client.read_namespaced_pod(pod.metadata.name,
pod.metadata.namespace)
+ if phase_tracker:
+ phase_tracker.update_from_pod(result)
+ return result
+ except ApiException as e:
+ if e.status == 404:
+ self._handle_pod_not_found(pod, phase_tracker)
+ raise
except HTTPError as e:
raise KubernetesApiException(f"There was an error reading the
kubernetes API: {e}")
+ def _handle_pod_not_found(self, pod: V1Pod, phase_tracker: PodPhaseTracker
| None) -> None:
Review Comment:
Sure, will consolidate under PodPhaseTracker.
--
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]