Skip to content

Kubernetes Pod Operator Task keeps Pod with Pending/Running state in detele_succeded_pod #59083

Closed

Description

@wolvery

Apache Airflow version

3.1.3

If "Other Airflow 2/3 version" selected, which one?

No response

What happened?

Hi!
We have detected that the Airflow Worker does not delete the Kubernetes Pod Operator for Pending/Running State while using the on_finish_action with DELETE_SUCCEEDED_POD.

What you think should happen instead?

I believe it should delete Pods with Pending state. Otherwise, they will consume resources. Only the failed should be Kept, so, we should change the logic to DELETE_NON_FAILED_POD.

How to reproduce

In case you spin up a KPO Pod without machine using DELETE_SUCCEEDED_POD for on_finish_action, and Airflow Worker timeout in the spin up, the Pod will be kept there waiting for a machine and if the machine become available it will start to run

Operating System

apache:airflow-3.1.3 on Kubernetes

Versions of Apache Airflow Providers

Kubernetes Provider only.

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. changed the title [-]Kubernetes Pod Operator Task keeps Pod with Pending state in detele_succeded_pod[/-] [+]Kubernetes Pod Operator Task keeps Pod with Pending/Running state in detele_succeded_pod[/+] on Dec 5, 2025
  2. shubham36deshpande commented on Dec 7, 2025

    @shubham36deshpande
    Contributor

    Hi @potiuk, this seems reasonable should we implement this?
    if yes, can I pick this issue up?

  3. SameerMesiah97 commented on Dec 7, 2025

    @SameerMesiah97
    Contributor

    @shubham36deshpande I am about to submit a PR for this. But if you have something ready, I think you can open it.

  4. SameerMesiah97 commented on Dec 7, 2025

    @SameerMesiah97
    Contributor

    The pull request #59160 has been opened to close this issue. I understand that the bug reporter requested the logic for
    'delete_succeeded_pod' to be changed to delete all pods that have not 'Failed' but this might risk breaking backwards compatibility. Therefore, I propose adding a new flag 'delete_active_pods' to handle the cleanup of zombie pods in 'Running' or 'Pending' state on task completion or termination.

    @wolvery @shubham36deshpande — please feel free to review or comment if you believe any scenarios are missing, or if you'd still prefer to propose an alternative approach.

  5. wolvery commented on Dec 14, 2025

    @wolvery
    ContributorAuthor

    hey @jscheffl, I believe we should delete the pods for all scenarios and not failed Pods.
    I created this PR, If you could review it, please:
    #59413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions