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

Move to watchtower 2.0.1 - Fixes Watchtower crash when logging empty line #19907

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

o-nikolas
Copy link
Contributor

@o-nikolas o-nikolas commented Nov 30, 2021

Overview

This version of watchtower contains patches (submitted by myself and Andrey the maintainer) that fixes #15279 where empty log lines would crash Watchtower.

Testing

I wrote a dag with the following benchmarks:

  • Log a single line from a task
  • Log an empty line
  • Log 1000 lines
  • Log 10,000 lines
  • Log 100,000 lines

I detected no noticeable regression in task run time, and as expected the new watchtower version does not crash when logging an empty line.

Note: The logic, as Andrey wrote it, ignores empty log lines and emits a warning message (see snippet below). The warning messages could be a nuisance if you're logging empty lines frequently, and it is possible to remove them, but I think it's a also a good indicator to the user that their remote logs will look different than they expect due to the empty messages being filtered. Let me know what you folks think.
Example output from my empty line benchmark task:

...
[2021-11-30, 19:22:45 UTC] Running command: ['bash', '-c', "echo ''"]
[2021-11-30, 19:22:45 UTC] Output:
[2021-11-30, 19:22:45 UTC] /usr/local/lib/python3.6/site-packages/watchtower/__init__.py:349 WatchtowerWarning: Received empty message. Empty messages cannot be sent to CloudWatch Logs
[2021-11-30, 19:22:45 UTC] Command exited with return code 0
...

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

- This version of watchtower contains patches that fixes apache#15279
  where empty log lines would crash Watchtower.
@@ -81,7 +81,7 @@ def set_context(self, ti):
self.handler = watchtower.CloudWatchLogHandler(
log_group=self.log_group,
stream_name=self._render_filename(ti, ti.try_number),
boto3_session=self.hook.get_session(self.region_name),
boto3_client=self.hook.get_conn(),
Copy link
Contributor Author

@o-nikolas o-nikolas Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watchtower now expects a Boto3 client instead of a session, this was changed in this commit: kislyuk/watchtower@a623250

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Dec 1, 2021
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk potiuk merged commit 2539cb4 into apache:main Dec 1, 2021
@potiuk potiuk added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jan 22, 2022
@potiuk potiuk added this to the Airflow 2.2.4 milestone Jan 22, 2022
potiuk pushed a commit that referenced this pull request Jan 22, 2022
- This version of watchtower contains patches that fixes #15279
  where empty log lines would crash Watchtower.

(cherry picked from commit 2539cb4)
jedcunningham pushed a commit that referenced this pull request Jan 27, 2022
- This version of watchtower contains patches that fixes #15279
  where empty log lines would crash Watchtower.

(cherry picked from commit 2539cb4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logging area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) full tests needed We need to run full set of tests for this PR to merge provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error on logging empty line to Cloudwatch
3 participants