This is an automated email from the ASF dual-hosted git repository.

jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new c51127ef435 Fix kubernetes cleanup-pods ignoring --verbose (#65955)
c51127ef435 is described below

commit c51127ef435799449d013711d6205b44d52c72c2
Author: Henry Chen <[email protected]>
AuthorDate: Sat May 9 21:05:13 2026 +0800

    Fix kubernetes cleanup-pods ignoring --verbose (#65955)
---
 .../providers/cncf/kubernetes/cli/kubernetes_command.py     | 13 ++++++++-----
 .../tests/unit/cncf/kubernetes/cli/test_definition.py       |  3 +++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py
 
b/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py
index 0d0d15c57b1..bc3389c0990 100644
--- 
a/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py
+++ 
b/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py
@@ -149,10 +149,11 @@ def cleanup_pods(args):
     # * OnFailure: Restart Container; Pod phase stays Running.
     # * Never: Pod phase becomes Failed.
     pod_restart_policy_never = "never"
-
-    print("Loading Kubernetes configuration")
+    if args.verbose:
+        print("Loading Kubernetes configuration")
     kube_client = get_kube_client()
-    print(f"Listing pods in namespace {namespace}")
+    if args.verbose:
+        print(f"Listing pods in namespace {namespace}")
     airflow_pod_labels = [
         "dag_id",
         "task_id",
@@ -165,7 +166,8 @@ def cleanup_pods(args):
         pod_list = kube_client.list_namespaced_pod(**list_kwargs)
         for pod in pod_list.items:
             pod_name = pod.metadata.name
-            print(f"Inspecting pod {pod_name}")
+            if args.verbose:
+                print(f"Inspecting pod {pod_name}")
             pod_phase = pod.status.phase.lower()
             pod_reason = pod.status.reason.lower() if pod.status.reason else ""
             pod_restart_policy = pod.spec.restart_policy.lower()
@@ -190,7 +192,8 @@ def cleanup_pods(args):
                 except ApiException as e:
                     print(f"Can't remove POD: {e}", file=sys.stderr)
             else:
-                print(f"No action taken on pod {pod_name}")
+                if args.verbose:
+                    print(f"No action taken on pod {pod_name}")
         continue_token = pod_list.metadata._continue
         if not continue_token:
             break
diff --git 
a/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/cli/test_definition.py 
b/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/cli/test_definition.py
index 4ffd0f224a9..8572473b836 100644
--- 
a/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/cli/test_definition.py
+++ 
b/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/cli/test_definition.py
@@ -85,10 +85,12 @@ class TestKubernetesCliDefinition:
             "my-namespace",
             "--min-pending-minutes",
             "60",
+            "--verbose",
         ]
         args = self.arg_parser.parse_args(params)
         assert args.namespace == "my-namespace"
         assert args.min_pending_minutes == 60
+        assert args.verbose is True
 
     def test_cleanup_pods_command_default_args(self):
         """Test cleanup-pods command with default arguments."""
@@ -97,6 +99,7 @@ class TestKubernetesCliDefinition:
         # Should use default values from configuration
         assert hasattr(args, "namespace")
         assert args.min_pending_minutes == 30
+        assert args.verbose is False
 
     def test_generate_dag_yaml_command_args(self):
         """Test generate-dag-yaml command with various arguments."""

Reply via email to