Vasu-Madaan opened a new pull request, #53477: URL: https://github.com/apache/airflow/pull/53477
Fixing #53472 This PR addresses a bug in the KubernetesPodOperator where pods were not being cleaned up correctly if they were created with labels that have a None value. This issue resulted in orphaned pods remaining in the Kubernetes namespace after task completion, even when on_finish_action was set to delete_pod. Problem The root cause was an inconsistency in how None values for labels were handled between pod creation and pod discovery for cleanup. Pod Creation: During pod creation, labels are processed and None values are converted to the string "" (e.g., my-label: ""). This is a valid label value in Kubernetes. Pod Discovery/Cleanup: When the operator later tried to find the pod for cleanup using _build_find_pod_label_selector, it would incorrectly format the label selector for labels with None values, often resulting in an empty None value instead of a blank string "" This mismatch between the label applied to the pod and the label selector used to find it meant the operator could not locate the pod it had created, and therefore could not delete it. Solution The fix aligns the label selector generation logic with the pod creation logic. The _build_find_pod_label_selector method has been updated to explicitly convert None values to the empty string "", ensuring the generated selector can successfully match the labels on the created pod. -- 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]
