Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing class constant to make worker pod log lines configurable #33378

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class PodReconciliationError(AirflowException):
class KubernetesExecutor(BaseExecutor):
"""Executor for Kubernetes."""

RUNNING_POD_LOG_LINES = 100
supports_ad_hoc_ti_run: bool = True

def __init__(self):
Expand Down Expand Up @@ -502,7 +503,7 @@ def get_task_log(self, ti: TaskInstance, try_number: int) -> tuple[list[str], li
namespace=namespace,
container="base",
follow=False,
tail_lines=100,
tail_lines=self.RUNNING_POD_LOG_LINES,
_preload_content=False,
)
for line in res:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ def test_delete_pod_404_not_raised(self, mock_watcher, mock_client, mock_kube_cl
finally:
kube_executor.end()

def test_running_pod_log_lines(self):
# default behaviour
kube_executor = KubernetesExecutor()
assert kube_executor.RUNNING_POD_LOG_LINES == 100

# monkey-patching for second executor
kube_executor_2 = KubernetesExecutor()
kube_executor_2.RUNNING_POD_LOG_LINES = 200

# monkey-patching should not affect the class constant
assert kube_executor.RUNNING_POD_LOG_LINES == 100
assert kube_executor_2.RUNNING_POD_LOG_LINES == 200


class TestKubernetesExecutor:
"""
Expand Down