-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Fix CloudwatchTaskHandler display error #54054
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
Fix CloudwatchTaskHandler display error #54054
Conversation
|
Just tested fixed CloudwatchTaskHandler with different airflow-core version setups and all of them display correctly. I setup the following airflow-core version matrix against fixed CloudwatchTaskHandler.
After fix, the log should be format correctly on frontend, screenshot as below |
ashb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still goes and loads everything into memory for Cloudwatch doesn't it? As we call io.read() which does [x for x in self.stream()] -- I wonder if the read code in file_task_handler should check for a io.stream function and use that in preference over io.read?
That might be a bit complex, but either way I think we need a bit more thought here to not undo all the changes you had for paging/oom of logs
Yes, I'm still WIP on local for setup stream-based read with backward compatibility.
I had considered compact mechanism in #49470 by peeking the type of the So we just need to make sure the provider with airflow-core after 3.0.3 version should return stream-based. # in `version_compat` module
# or maybe just use `get_base_airflow_version_tuple() >= (3, 0, 3)` directly in provider FileTaskHandler
STREAM_BASED_READ = get_base_airflow_version_tuple() >= (3, 0, 3)
# in provider FileTaskHandler
if STREAM_BASED_READ:
return messages, log_streams # generator of StructuredLogMessage or str
else:
return messages, log_list # list of str ( not memory efficient, but only after 3.0.3 airflow-core can support stream-based read ) |
7e5785d to
de079f2
Compare
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Outdated
Show resolved
Hide resolved
de079f2 to
4832d37
Compare
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Show resolved
Hide resolved
ffa3797 to
5a775df
Compare
30a2528 to
847a238
Compare
a2eb6dd to
f615e0d
Compare
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR should be good to go, I just test it with both Airflow 3 and Airflow 2 with the following setup and both work well.
breeze start-airflow --backend postgres --integration localstack --db-reset --mount-sources providers-and-tests --use-airflow-version 3.1.3
breeze start-airflow --backend postgres --integration localstack --mount-sources providers-and-tests --use-airflow-version 2.11.0
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py
Outdated
Show resolved
Hide resolved
f615e0d to
756b80f
Compare
|
looks like we have some compatibility issue 🤔 |
756b80f to
e0d5f74
Compare
4d5d055 to
ea8d041
Compare
- .stream method should return gen[str] but it return in gen[dict] in previous fix - Make _parse_cloudwatch_log_event return as str intead of dict can fix the problem
- consolidate str_logs - rename _event_to_dict
ea8d041 to
0e90658
Compare
* Take over ash's fix * Fix datetime serialization error * Fix 'generator is not subscriptable' error * Fix test_cloudwatch_task_handler * Fix nits in code review * Add CloudWatchLogEvent type * Correct return type of .stream method - .stream method should return gen[str] but it return in gen[dict] in previous fix - Make _parse_cloudwatch_log_event return as str intead of dict can fix the problem * Revert change in file_task_handler * Fix test_log_message * Revert file_task_handler change * Fix type annotation for CloudWatchRemoteLogIO * Fix review comments - consolidate str_logs - rename _event_to_dict








related: #49470
Why
As noted in #49470 (comment), PR #49470 unintentionally broke the display format of
CloudWatchHandler.What
This PR fixes the display issue for
CloudWatchHandlerand ensure it will display properly across differentairflow-coreversions.