wolfdn opened a new pull request, #33914: URL: https://github.com/apache/airflow/pull/33914
We are using the DockerOperator and noticed that the logs are a bit confusing when there is an error in a Docker container (return code != 0) because Airflow shows the log output of the Docker container 3 times. The logs of a failed run with the DockerOperator currently look like this: ``` [2023-08-29T13:12:32.261+0000] {docker.py:160} INFO - << log line from Docker container >> [2023-08-29T13:12:34.308+0000] {docker.py:474} INFO - << log line from Docker container >> [2023-08-29T13:12:34.308+0000] {docker.py:474} INFO - << log line from Docker container >> ... ... ... [2023-08-29T13:39:15.959+0000] {taskinstance.py:1943} ERROR - Task failed with exception Traceback (most recent call last): File "/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/docker/operators/docker.py", line 476, in execute return self._run_image() File "/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/docker/operators/docker.py", line 338, in _run_image return self._run_image_with_mounts(self.mounts + [tmp_mount], add_tmp_variable=True) File "/home/airflow/.local/lib/python3.8/site-packages/airflow/providers/docker/operators/docker.py", line 411, in _run_image_with_mounts raise AirflowException(f"Docker container failed: {repr(result)} lines {joined_log_lines}") airflow.exceptions.AirflowException: Docker container failed: {'StatusCode': 1} lines << log line from Docker container >> << log line from Docker container >> << log line from Docker container >> ... ... ... [2023-08-29T13:39:15.991+0000] {taskinstance.py:1400} INFO - Marking task as FAILED. dag_id=<< dag id >>, task_id=<< task id >>, execution_date=20230829T131212, start_date=20230829T131229, end_date=20230829T133915 [2023-08-29T13:39:16.226+0000] {standard_task_runner.py:104} ERROR - Failed to execute job 1948 for task << task id >> (Docker container failed: {'StatusCode': 1} lines << log line from Docker container >> << log line from Docker container >> << log line from Docker container >> ... ... ... [2023-08-29T13:39:16.248+0000] {local_task_job_runner.py:228} INFO - Task exited with return code 1 [2023-08-29T13:39:16.463+0000] {taskinstance.py:2784} INFO - 0 downstream tasks scheduled from follow-on schedule check ``` This PR removes the output of the Docker container from the Airflow exception that is thrown. With this change the log output of the Docker container is only shown one single time in Airflow (regardless of the return code). <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Thank you for contributing! Please make sure that your code changes are covered with tests. And in case of new features or big changes remember to adjust the documentation. Feel free to ping committers for the review! In case of an existing issue, reference it using one of the following: closes: #ISSUE related: #ISSUE How to write a good git commit message: http://chris.beams.io/posts/git-commit/ --> <!-- Please keep an empty line above the dashes. --> --- **^ Add meaningful description above** Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information. In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed. In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments). -- 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. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org