Re: [PR] Improve logging readability with DockerOperator [airflow]
github-actions[bot] closed pull request #38008: Improve logging readability with DockerOperator URL: https://github.com/apache/airflow/pull/38008 -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
github-actions[bot] commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2101697150 This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1536864652 ## airflow/providers/docker/operators/docker.py: ## @@ -423,13 +447,19 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: -self.cli.start(self.container["Id"]) - -log_lines = [] -for log_chunk in logstream: -log_chunk = stringify(log_chunk).strip() -log_lines.append(log_chunk) -self.log.info("%s", log_chunk) +if self.container_log_formatter is not None: +self._change_log_formatters(self.container_log_formatter) + +try: +self.cli.start(self.container["Id"]) + +log_lines = [] +for log_chunk in logstream: +log_chunk = stringify(log_chunk).strip() +log_lines.append(log_chunk) +self.log.info("%s", log_chunk) +finally: +self._restore_log_formatters() Review Comment: Right now this is not yet complete. What happens if `self.container_log_formatter` is Nonne - we will still run `_restore` it seems? -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2016229746 > ``` > change() > try: >do stuff > finally: >restore() > ``` Ha! I misunderstood which try-catch block you were mentioning before. Updated, this is indeed a good catch, 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. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2016154715 ``` change() try: do stuff finally: restore() ``` -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2016091345 > Still try/finally not solved Can you be more specific please @potiuk? Because we indeed added `_restore_log_formatter` into the except clause, which will revert the changes if formatters are not fully updated to the customized one. If you are referring to the original suggestion: > Maybe I am nissing something I thought about try/finally where _restore_log_formatter will be called in the finally clause. I think we've confused something here, because `_restore_log_formatter` will roll back all formatters no matter the try block succeeded or not, and makes this feature not working anymore. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2016055030 Still try/finally not solved -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2015985430 > conflicts to resolve when rebasing. Resolved. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-2015980402 conflicts to resolve when rebasing. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1531011245 ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: That makes sense. Updated :) However I think except would be more appropriate here, rather than finally. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1531011245 ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: That makes sense. Updates :) ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: That makes sense. Updated :) -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1530952462 ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: Hmm. Maybe I am nissing something I thought about try/finally where `_restore_log_formatter` will be called in the finally clause. -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1530899050 ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: Added. Thank you for the review! -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
potiuk commented on code in PR #38008: URL: https://github.com/apache/airflow/pull/38008#discussion_r1530319242 ## airflow/providers/docker/operators/docker.py: ## @@ -420,6 +434,8 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[ ) logstream = self.cli.attach(container=self.container["Id"], stdout=True, stderr=True, stream=True) try: +self._change_log_formatters() + Review Comment: Can you add try/finally clause? what happens if there is an exception thrown inside? -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-1993759478 > Can you add the test cases for this change? Change has been made in the new PR. Further review will be very welcomed and appreciated. @dirrao -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-1993756566 > I find it as a useful optional feature, but it absolutely cannot be enabled by default. It should be quite a bit more generic also in order to be useful - you should be able to not only enable it, but also provide an optional formatting + documentation and examples of usage in HowTo as well. It also needs unit tests testing it. Good insights. I pushed a new commit based on these points. @potiuk -- 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
Re: [PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-1986847704 Hi @potiuk, I've added a PR to address your [previous discussion](https://github.com/apache/airflow/discussions/29302) with [MattiaGallegati](https://github.com/MattiaGallegati). Would like to have your review on this. 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. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Improve logging readability with DockerOperator [airflow]
boring-cyborg[bot] commented on PR #38008: URL: https://github.com/apache/airflow/pull/38008#issuecomment-1986846284 Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points: - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that. - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it. - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations. - Be patient and persistent. It might take some time to get a review or get the final approval from Committers. - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack. - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices). - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: d...@airflow.apache.org Slack: https://s.apache.org/airflow-slack -- 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
[PR] Improve logging readability with DockerOperator [airflow]
lyuyunbo opened a new pull request, #38008: URL: https://github.com/apache/airflow/pull/38008 Related: [discussion](https://github.com/apache/airflow/discussions/29302) When DockerOperator logs are displayed in the Airflow UI, the logs from the container are prefixed with "[asctime UTC] {docker.py:[line]} INFO -" in some "random" lines. This prefix can disrupt the logging format inside the container and is often redundant: - [asctime UTC]: This timestamp may duplicate timestamps already present in the container logs - {docker.py:[line]}: This information is constant when the container is running and provides little value - INFO: The logging level is often misleading, as the actual log content may be of a different severity This PR removes these three components from the logging prefix and only displaying the logs from the container, which aims to enhance the readability of the entire logging output. -- 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