-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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 task_instance can not get task attribute correctly when turning on sentry #36968
fix task_instance can not get task attribute correctly when turning on sentry #36968
Conversation
31880fe
to
cd40c4c
Compare
cd40c4c
to
69e23d8
Compare
7bccb9b
to
040f23b
Compare
I'm not totally convinced this is the best fix. Per my comment I don't think |
53fa87c
to
9f5e895
Compare
I thought we still wanted to have enriched errors when we scheduled the tasks because errors might also occur at scheduling time. But I too don't have the full context of why this was designed this way back then 🤔 |
@@ -178,8 +179,12 @@ def wrapper(_self, *args, **kwargs): | |||
|
|||
with sentry_sdk.push_scope(): | |||
try: | |||
# Is a LocalTaskJob get the task instance | |||
if hasattr(_self, "task_instance"): | |||
ti_from_kwargs = kwargs.get("ti", None) |
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.
why task instance is mandatory for sentry error logging?
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.
It's needed by add_tagging
and add_breadcrumbs
…_tasks and _run_raw_task are decorated with error
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
… and _run_raw_task are decorated with error
9f5e895
to
0750bb8
Compare
Closes: #36957
As reported by @jkramer-ginkgo, we also encountered a similar issue, and I'm able to reproduce it with the steps provided. Among the suggested solutions by @jkramer-ginkgo , I think it might make more sense to get
ti
fromkwargs
instead of removing this decorator. The root cause is thatairflow/airflow/models/taskinstance.py
Line 3225 in db2b75c
task
attributeairflow/airflow/sentry.py
Line 127 in db2b75c
_schedule_downstream_tasks
arguments to be keyword-lonly so that we can ensure that we can get ti from kwargs inenrich_error
.^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an 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 a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.