jedcunningham commented on code in PR #70595:
URL: https://github.com/apache/airflow/pull/70595#discussion_r3676218769


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py:
##########
@@ -173,15 +200,18 @@ def cleanup_pods(args):
             pod_restart_policy = pod.spec.restart_policy.lower()
             current_time = datetime.now(pod.metadata.creation_timestamp.tzinfo)
 
-            if (
+            is_terminal = (
                 pod_phase == pod_succeeded
                 or (pod_phase == pod_failed and pod_restart_policy == 
pod_restart_policy_never)
                 or (pod_reason == pod_reason_evicted)
-                or (
-                    pod_phase == pod_pending
-                    and current_time - pod.metadata.creation_timestamp
-                    > timedelta(minutes=min_pending_minutes)
-                )
+            )
+            is_terminal_old_enough = is_terminal and (
+                min_completed_minutes == 0
+                or current_time - _get_pod_completion_time(pod) > 
timedelta(minutes=min_completed_minutes)
+            )
+            if is_terminal_old_enough or (
+                pod_phase == pod_pending
+                and current_time - pod.metadata.creation_timestamp > 
timedelta(minutes=min_pending_minutes)

Review Comment:
   Lets pull this into a separate flag too while we are here.



-- 
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]

Reply via email to