Fix TI failure handling when task cannot be unmapped.#23119
Merged
Conversation
At first glance this looks like a lot of un-related changed, but it is all related to handling errors in unmapping: - Ensure that SimpleTaskInstance (and thus the Zombie callback) knows about map_index, and simplify the code for SimpleTaskInstance -- no need for properties, just attributes works. - Be able to create a TaskFail from a TI, not a Task. This is so that we can create the TaskFail with the mapped task so we can delay unmapping the task in TI.handle_failure as long as possible. - Change email_alert and get_email_subject_content to take the task so we can pass the unmapped Task around.
jedcunningham
approved these changes
Apr 20, 2022
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
jedcunningham
approved these changes
Apr 21, 2022
uranusjr
reviewed
Apr 21, 2022
Comment on lines
-1907
to
+1908
| Stats.incr(f'operator_failures_{task.task_type}', 1, 1) | ||
| Stats.incr(f'operator_failures_{self.task.task_type}') |
uranusjr
reviewed
Apr 21, 2022
| try: | ||
| task = self.task.unmap() | ||
| except Exception: | ||
| self.log.error("Unable to unmap task, can't determine if we need to send an alert email or not") |
Member
There was a problem hiding this comment.
Should we log the traceback here with exception() instead?
uranusjr
reviewed
Apr 21, 2022
| task = dag.get_task(simple_ti.task_id) | ||
| if request.is_failure_callback: | ||
| ti = TI(task, run_id=simple_ti.run_id) | ||
| ti = TI(task, run_id=simple_ti.run_id, map_index=simple_ti.map_index) |
Member
There was a problem hiding this comment.
Perhaps we should revive #19242, it can make the TI <-> SimpleTI conversions more future-proof.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At first glance this looks like a lot of un-related changed, but it is
all related to handling errors in unmapping:
Ensure that SimpleTaskInstance (and thus the Zombie callback) knows
about map_index, and simplify the code for SimpleTaskInstance -- no
need for properties, just attributes works.
Be able to create a TaskFail from a TI, not a Task.
This is so that we can create the TaskFail with the mapped task so we
can delay unmapping the task in TI.handle_failure as long as possible.
Change email_alert and get_email_subject_content to take the task so
we can pass the unmapped Task around.
Fixes #23107
^ 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.