Skip to content

Commit 38aada7

Browse files
authored
Introducing class constant to make worker pod log lines configurable (#33378)
1 parent 5e1e5fa commit 38aada7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class PodReconciliationError(AirflowException):
147147
class KubernetesExecutor(BaseExecutor):
148148
"""Executor for Kubernetes."""
149149

150+
RUNNING_POD_LOG_LINES = 100
150151
supports_ad_hoc_ti_run: bool = True
151152

152153
def __init__(self):
@@ -502,7 +503,7 @@ def get_task_log(self, ti: TaskInstance, try_number: int) -> tuple[list[str], li
502503
namespace=namespace,
503504
container="base",
504505
follow=False,
505-
tail_lines=100,
506+
tail_lines=self.RUNNING_POD_LOG_LINES,
506507
_preload_content=False,
507508
)
508509
for line in res:

tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ def test_delete_pod_404_not_raised(self, mock_watcher, mock_client, mock_kube_cl
228228
finally:
229229
kube_executor.end()
230230

231+
def test_running_pod_log_lines(self):
232+
# default behaviour
233+
kube_executor = KubernetesExecutor()
234+
assert kube_executor.RUNNING_POD_LOG_LINES == 100
235+
236+
# monkey-patching for second executor
237+
kube_executor_2 = KubernetesExecutor()
238+
kube_executor_2.RUNNING_POD_LOG_LINES = 200
239+
240+
# monkey-patching should not affect the class constant
241+
assert kube_executor.RUNNING_POD_LOG_LINES == 100
242+
assert kube_executor_2.RUNNING_POD_LOG_LINES == 200
243+
231244

232245
class TestKubernetesExecutor:
233246
"""

0 commit comments

Comments
 (0)