This is an automated email from the ASF dual-hosted git repository. jhtimmins pushed a commit to branch v2-1-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 8e8b58aa0a96164c7142d795a9c919d50e2a9aa1 Author: Damir Lampa <60409723+dla...@users.noreply.github.com> AuthorDate: Thu Jul 29 14:17:51 2021 -0600 Fix CLI 'kubernetes cleanup-pods' which fails on invalid label key (#17298) Fix for #16013 - CLI 'kubernetes cleanup-pods' fails on invalid label key (cherry picked from commit 36bdfe8d0ef7e5fc428434f8313cf390ee9acc8f) --- airflow/cli/commands/kubernetes_command.py | 12 ++---------- tests/cli/commands/test_kubernetes_command.py | 8 ++------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/airflow/cli/commands/kubernetes_command.py b/airflow/cli/commands/kubernetes_command.py index 3c3c8e6..2660dae 100644 --- a/airflow/cli/commands/kubernetes_command.py +++ b/airflow/cli/commands/kubernetes_command.py @@ -96,16 +96,8 @@ def cleanup_pods(args): 'try_number', 'airflow_version', ] - list_kwargs = { - "namespace": namespace, - "limit": 500, - "label_selector": client.V1LabelSelector( - match_expressions=[ - client.V1LabelSelectorRequirement(key=label, operator="Exists") - for label in airflow_pod_labels - ] - ), - } + list_kwargs = {"namespace": namespace, "limit": 500, "label_selector": ','.join(airflow_pod_labels)} + while True: pod_list = kube_client.list_namespaced_pod(**list_kwargs) for pod in pod_list.items: diff --git a/tests/cli/commands/test_kubernetes_command.py b/tests/cli/commands/test_kubernetes_command.py index f2a8605..490c7fa 100644 --- a/tests/cli/commands/test_kubernetes_command.py +++ b/tests/cli/commands/test_kubernetes_command.py @@ -55,12 +55,8 @@ class TestGenerateDagYamlCommand(unittest.TestCase): class TestCleanUpPodsCommand(unittest.TestCase): - label_selector = kubernetes.client.V1LabelSelector( - match_expressions=[ - kubernetes.client.V1LabelSelectorRequirement(key=label, operator="Exists") - for label in ['dag_id', 'task_id', 'execution_date', 'try_number', 'airflow_version'] - ] - ) + + label_selector = ','.join(['dag_id', 'task_id', 'execution_date', 'try_number', 'airflow_version']) @classmethod def setUpClass(cls):