mik-laj commented on a change in pull request #15204:
URL: https://github.com/apache/airflow/pull/15204#discussion_r607138403



##########
File path: airflow/cli/commands/kubernetes_command.py
##########
@@ -90,7 +90,25 @@ def cleanup_pods(args):
     print('Loading Kubernetes configuration')
     kube_client = get_kube_client()
     print(f'Listing pods in namespace {namespace}')
-    list_kwargs = {"namespace": namespace, "limit": 500}
+    airflow_pod_labels = [
+        'airflow-worker',
+        'dag_id',
+        'task_id',
+        'execution_date',
+        'try_number',
+        'airflow_version',
+        'kubernetes_executor',
+    ]
+    list_kwargs = {
+        "namespace": namespace,
+        "limit": 500,
+        "label_selector": client.V1LabelSelector(
+            match_expressions=[
+                client.V1LabelSelectorRequirement(key=label, operator="Exists")

Review comment:
       > The requirements are ANDed.
   
   This command should also work when the pod does not contain 
`kubernetes_executor` label i.e. it is started by KubernetetsPodOperator.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to