You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:31:58 UTC

[GitHub] [airflow] the-horhe opened a new issue #9190: DockerOperator loosing some initial container output

the-horhe opened a new issue #9190:
URL: https://github.com/apache/airflow/issues/9190


   **Apache Airflow version**: 1.10.10
   
   **Environment**: official docker image apache/airflow:1.10.10, docker api version: 1.40
   
   **What happened**:
   Don't see any container output in task logs when using DockerOperator with short living containers.
   
   **What you expected to happen**:
   Expected to see container stdout/stderr
   
   It seems the problem is here: https://github.com/apache/airflow/blob/v1-10-stable/airflow/operators/docker_operator.py#L232
   1. Containers is being started
   2. We attach to container output
   
   But all output between steep 1 and to 2 seems to be lost.
   
   I found a simple solution - adding `logs=True` to self.cli.attach fixes the problem
   https://github.com/apache/airflow/blob/v1-10-stable/airflow/operators/docker_operator.py#L235
   According to docker API documentation (https://docs.docker.com/engine/api/v1.40.yaml - line 6052) solution seems legit.
   
   **How to reproduce it**:
   
   ```
   from datetime import timedelta
   from airflow.utils.dates import days_ago
   from airflow import DAG
   from airflow.operators.docker_operator import DockerOperator
   
   
   default_args = {
       'owner': 'airflow',
       'depends_on_past': True,
       'wait_for_downstream': True,
       'catchup': True,
       'start_date': days_ago(2),
       'retries': 1,
       'retry_delay': timedelta(minutes=5),
   }
   dag = DAG(
       'docker_dag',
       default_args=default_args,
       description='',
       schedule_interval=timedelta(days=1),
   )
   
   run_gsc_crawlers = DockerOperator(
       task_id='print_hello_world',
       image='centos:latest',
       api_version='auto',
       auto_remove=True,
       command='/bin/bash -c \'echo "HELLO WORLD!"\'',
       docker_url='unix://var/run/docker.sock',
       network_mode='bridge',
       dag=dag,
   )
   ```
   Output without logs=True:
   ![image](https://user-images.githubusercontent.com/12816025/84119285-d0704600-aa3c-11ea-8f4b-f7a12a889c24.png)
   
   Output without logs=True but with slow starting container (command `/bin/bash -c \'sleep 5 && echo "HELLO WORLD!"\'`):
   ![image](https://user-images.githubusercontent.com/12816025/84119528-2ba23880-aa3d-11ea-9186-bc0a9e2d0ffe.png)
   ^ ok - notice string with "INFO - HELLO WORLD!"
   
   Output with original command and logs=True:
   ![image](https://user-images.githubusercontent.com/12816025/84119853-ab300780-aa3d-11ea-801d-1155b02732e0.png)
   ^ ok - notice string with "INFO - HELLO WORLD!"


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] nullhack edited a comment on issue #9190: DockerOperator loosing some initial container output

Posted by GitBox <gi...@apache.org>.
nullhack edited a comment on issue #9190:
URL: https://github.com/apache/airflow/issues/9190#issuecomment-641245736






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] the-horhe commented on issue #9190: DockerOperator loosing some initial container output

Posted by GitBox <gi...@apache.org>.
the-horhe commented on issue #9190:
URL: https://github.com/apache/airflow/issues/9190#issuecomment-641765428


   Tested with `auto_remove=False` - it seems it has no effect. Did't try with `apache/airflow:master-ci` though yet.
   Also modified command to `/bin/bash -c \'echo "1" && sleep 5 && echo "2"\` and see only `2` in logs, so to me it seems the problem is a late container connection.
   
   @nullhack it is the first time we try to use DockerOperator, so don't have much to say 8( 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #9190: DockerOperator loosing some initial container output

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #9190:
URL: https://github.com/apache/airflow/issues/9190#issuecomment-641100635


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [airflow] nullhack commented on issue #9190: DockerOperator loosing some initial container output

Posted by GitBox <gi...@apache.org>.
nullhack commented on issue #9190:
URL: https://github.com/apache/airflow/issues/9190#issuecomment-641245736


   This can be related to a recently merged [PR](https://github.com/apache/airflow/pull/9173).
   
   I tried to run on the docker image `apache/airflow:master-ci` and the output was as expected.
   
   ![image](https://user-images.githubusercontent.com/11466701/84144441-d55be680-aa8a-11ea-8021-e3aee6bb6bdf.png)
   
   If this is the case, It's related to the `auto_remove=True`, (the container gets removed before The task can get the `stdout`). If not, can be related to the `issue 1` of https://github.com/apache/airflow/issues/9164
   
   @the-horhe If you use `DockerOperator` a lot, can you give a feedback on thi [issue/PR](https://github.com/apache/airflow/issues/9164) I proposed some days ago ? Thanks.


----------------------------------------------------------------
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:
users@infra.apache.org