SameerMesiah97 commented on code in PR #68507:
URL: https://github.com/apache/airflow/pull/68507#discussion_r3408643789
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -1228,12 +1228,20 @@ def cleanup(
istio_enabled = self.is_istio_enabled(remote_pod)
pod_phase = remote_pod.status.phase if hasattr(remote_pod, "status")
else None
- # if the pod fails or success, but we don't want to delete it
- if (
- pod_phase != PodPhase.SUCCEEDED
- or self.on_finish_action == OnFinishAction.KEEP_POD
- or self.on_finish_action == OnFinishAction.DELETE_ACTIVE_POD
- ):
+ should_delete = (
+ self.on_finish_action == OnFinishAction.DELETE_POD
+ or (
+ self.on_finish_action == OnFinishAction.DELETE_SUCCEEDED_POD
+ and pod_phase == PodPhase.SUCCEEDED
+ )
+ or (
+ self.on_finish_action == OnFinishAction.DELETE_ACTIVE_POD
+ and pod_phase in {PodPhase.RUNNING, PodPhase.PENDING}
+ )
+ )
+
+ # Patch the pod unless it is a succeeded pod that will be deleted.
+ if not (pod_phase == PodPhase.SUCCEEDED and should_delete):
Review Comment:
Done. Though it makes the PR rather trivial.
I still think the existing check for patching the pod was difficult to
understand. This should make it a bit more readable.
--
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]