forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure Executors properly trap errors
SequentialExecutor and LocalExecutor execute `airflow run` commands with `subprocess.Popen().wait()` and try to catch errors with `try/except`. However, `subprocess.Popen()` doesn't raise errors; you have to check the `returncode`. As a result, these Executors always report that their commands are successful. This is normally fine because task status gets precedence over executor status, so as long as the task reports on itself correctly the issue is avoided. But if an error is raised BEFORE a task runs -- meaning the task is not yet monitoring its own status -- then the executor will incorrectly report success. Airflow will actually notice something went wrong, but because the task doesn't say it failed, it gets rescheduled, leading to an infinite loop. To resolve this, replace the Executor's `Popen().wait()` with `check_call()`, which is a blocking method that raises an error if the returncode != 0. This way, errors are properly recognized. Also, prevent infinite loops by limiting the number of times a task is allowed to be rescheduled due to executor failure to 3. (Note: this doesn't affect the number of times a task can be rescheduled due to its own failure). Last, check for an odd situation where the executor reports failure but the task reports running. Closes apache#1199 See apache#1220 for a test case
- Loading branch information
Showing
3 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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