amoghrajesh commented on code in PR #77197:
URL: https://github.com/apache/airflow/pull/77197#discussion_r4715789427
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -1435,6 +1461,15 @@ def cleanup(
if self._killed or not remote_pod:
return
+ if self._keep_pod_after_timeout:
+ self.log.info(
+ "Task interrupted by execution_timeout and on_kill_action is
%r, keeping pod %s "
+ "so the next try can reattach.",
+ self.on_kill_action.value,
+ cast("k8s.V1ObjectMeta", remote_pod.metadata).name,
+ )
+ return
Review Comment:
`post_complete_action` now returns before the `on_pod_cleanup` callbacks
when the pod is kept, so they run on the try that actually cleans the pod up.
The timeout test asserts they are not called for the kept case.
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -779,6 +788,11 @@ def get_or_create_pod(self, pod_request_obj: k8s.V1Pod,
context: Context) -> k8s
if pod_phase == PodPhase.SUCCEEDED:
Stats.incr("resumable_job.already_succeeded",
tags=stats_tags)
+ # Without XCom there is nothing left to read from the pod,
so a pod that finished
+ # after its try was interrupted (e.g. a kept pod after a
timeout) is this try's run.
+ if not self.do_xcom_push:
Review Comment:
Added to the docs: a clear also reattaches to a kept pod, and with
`do_xcom_push=False` a pod that already succeeded marks the cleared task
successful, so delete the pod before clearing to start over.
--
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]