SamWheating commented on issue #10586:
URL: https://github.com/apache/airflow/issues/10586#issuecomment-683942214
Replicated the issue in Airflow 1.10.12 like so:
Created a DAG to really quickly log a bunch of stuff in a k8s pod:
```python
from datetime import timedelta
from airflow import models
from airflow import utils
from airflow.contrib.operators.kubernetes_pod_operator import
KubernetesPodOperator
dag = models.DAG(
'data-infrastructure-examples.sam-k8s-fast-logging',
start_date=utils.dates.days_ago(1),
max_active_runs=1,
dagrun_timeout=timedelta(minutes=1),
schedule_interval=None
)
hello_world_pod =
KubernetesPodOperator(namespace='data-infrastructure-examples',
image="busybox",
name="count-to-10000",
in_cluster=True,
task_id="count-to-10000",
get_logs=True,
dag=dag,
is_delete_operator_pod=False,
cmds=['seq', '10000']
)
```
Running the DAG then only provides the last 10 lines of the log in the
airflow UI:
```
[2020-08-31 18:08:08,673] {taskinstance.py:901} INFO - Executing
<Task(KubernetesPodOperator): count-to-10000> on
2020-08-31T18:08:01.278616+00:00
[2020-08-31 18:08:08,678] {standard_task_runner.py:54} INFO - Started
process 34196 to run task
[2020-08-31 18:08:08,848] {standard_task_runner.py:77} INFO - Running:
['airflow', 'run', 'data-infrastructure-examples.sam-k8s-fast-logging',
'count-to-10000', '2020-08-31T18:08:01.278616+00:00', '--job_id', '57658',
'--pool', 'default_pool', '--raw', '-sd',
'DAGS_FOLDER/data_infrastructure_examples/kubernetes_fast_logs.py',
'--cfg_path', '/tmp/tmp1jvekhel']
[2020-08-31 18:08:08,849] {standard_task_runner.py:78} INFO - Job 57658:
Subtask count-to-10000
[2020-08-31 18:08:08,955] {logging_mixin.py:112} INFO - Running %s on host
%s <TaskInstance:
data-infrastructure-examples.sam-k8s-fast-logging.count-to-10000
2020-08-31T18:08:01.278616+00:00 [running]> airflow-worker-7dcb77d8dc-bfxnw
[2020-08-31 18:08:09,027] {logging_mixin.py:112} WARNING -
/usr/local/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py:330:
DeprecationWarning: Using `airflow.contrib.kubernetes.pod.Pod` is deprecated.
Please use `k8s.V1Pod`.
security_context=_extract_security_context(pod.spec.security_context)
[2020-08-31 18:08:09,027] {logging_mixin.py:112} WARNING -
/usr/local/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py:77:
DeprecationWarning: Using `airflow.contrib.kubernetes.pod.Pod` is deprecated.
Please use `k8s.V1Pod` instead.
pod = self._mutate_pod_backcompat(pod)
[2020-08-31 18:08:09,699] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Pending
[2020-08-31 18:08:09,699] {pod_launcher.py:139} WARNING - Pod not yet
started: count-to-10000-f146290239a24243b48f8dbf0a26c8e5
[2020-08-31 18:08:10,709] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Pending
[2020-08-31 18:08:10,709] {pod_launcher.py:139} WARNING - Pod not yet
started: count-to-10000-f146290239a24243b48f8dbf0a26c8e5
[2020-08-31 18:08:11,716] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Pending
[2020-08-31 18:08:11,716] {pod_launcher.py:139} WARNING - Pod not yet
started: count-to-10000-f146290239a24243b48f8dbf0a26c8e5
[2020-08-31 18:08:12,725] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Succeeded
[2020-08-31 18:08:12,726] {pod_launcher.py:287} INFO - Event with job id
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 Succeeded
[2020-08-31 18:08:12,751] {pod_launcher.py:156} INFO - b'9991\n'
[2020-08-31 18:08:12,751] {pod_launcher.py:156} INFO - b'9992\n'
[2020-08-31 18:08:12,751] {pod_launcher.py:156} INFO - b'9993\n'
[2020-08-31 18:08:12,751] {pod_launcher.py:156} INFO - b'9994\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'9995\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'9996\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'9997\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'9998\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'9999\n'
[2020-08-31 18:08:12,752] {pod_launcher.py:156} INFO - b'10000\n'
[2020-08-31 18:08:12,766] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Succeeded
[2020-08-31 18:08:12,766] {pod_launcher.py:287} INFO - Event with job id
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 Succeeded
[2020-08-31 18:08:12,772] {pod_launcher.py:173} INFO - Event:
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 had an event of type Succeeded
[2020-08-31 18:08:12,772] {pod_launcher.py:287} INFO - Event with job id
count-to-10000-f146290239a24243b48f8dbf0a26c8e5 Succeeded
[2020-08-31 18:08:12,793] {taskinstance.py:1070} INFO - Marking task as
SUCCESS.dag_id=data-infrastructure-examples.sam-k8s-fast-logging,
task_id=count-to-10000, execution_date=20200831T180801,
start_date=20200831T180808, end_date=20200831T180812
[2020-08-31 18:08:13,568] {local_task_job.py:102} INFO - Task exited with
return code 0
```
While checking the logs on the completed pod show the entire count:
```
> kubectl logs -f -n data-infrastructure-examples
count-to-10000-f146290239a24243b48f8dbf0a26c8e5
1
2
3
4
5
6
(all the other numbers in the sequence)
9999
10000
```
----------------------------------------------------------------
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]