-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Move UPSTREAM_FAILED to Terminal State and Add State Validation Tests #53000
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 UPSTREAM_FAILED to Terminal State and Add State Validation Tests #53000
Conversation
|
@o-nikolas if you don't mind, let me know what you think |
I like this change. All the sets that we have for specific terminal states (I think it's just Only concern I'd have is what you mention, the changes propagating in ways we don't expect, but I don't think this is insurmountable and I'd be interested to see hear how many tests failed because of this change. |
|
@o-nikolas Tests passing, ready for review. |
eladkal
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.
It feels strange that none of our current tests needed modification due to this PR.
Like Niko I do have concerns that this change might cause unexpected behaviour. I see that the TerminalStateNonSuccess class is referenced in:
airflow/task-sdk/src/airflow/sdk/api/client.py
Lines 151 to 159 in ac9e968
| def finish(self, id: uuid.UUID, state: TerminalStateNonSuccess, when: datetime, rendered_map_index): | |
| """Tell the API server that this TI has reached a terminal state.""" | |
| if state == TaskInstanceState.SUCCESS: | |
| raise ValueError("Logic error. SUCCESS state should call the `succeed` function instead") | |
| # TODO: handle the naming better. finish sounds wrong as "even" deferred is essentially finishing. | |
| body = TITerminalStatePayload( | |
| end_date=when, state=TerminalStateNonSuccess(state), rendered_map_index=rendered_map_index | |
| ) | |
| self.client.patch(f"task-instances/{id}/state", content=body.model_dump_json()) |
This means that after this change UPSTREAM_FAILED will be processed differently. Do we know the implication of this?
If I read this right it may implicate on the end date of the task which can affect metrics collection. This may be a welcomed change but we need to be very sure that the all behavioral changes are expected.
This is one of the PRs that we should get several approval just to make sure we are making the right change. I would also ask to include newsfragment for this change.
airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py
Outdated
Show resolved
Hide resolved
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.
Setting temporary block to avoid accidental merge
Any maintainer may lift this block if
This is one of the PRs that we should get several approvals just to make sure we are making the right change.
If satisfied or no longer relevant.
|
@kaxil Since you created the |
kaxil
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.
UPSTREAM_FAILED change looks good but adding of removed to success_states does not
… completely cover terminal states
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.
Looks good but need to address 2 comments
…ates with success and failure sets
In my opinion, |
* Add MwaaTaskSensor to Amazon Provider Package * include pre-commit hooks * - Comply with PR #51196: explicitly pass to its superclass, and adjust the default value of in base class to . - Add defensive test around adding more task instance states to keep of the MwaaTaskCompletedTrigger up to date. - Fix issue where of the MwaaTaskSensor derives to instead of type. - Modify documentation to clearly indicate that the MwaaTaskSensor is meant to sense tasks across different MWAA environments. - Make an optional parameter, where it defaults to the latest dag run. - Externally fetch the task ID variable. - Test the sensor while a DAG Run is still in progress. * documentation update * Response to PR #51719 comments - Brought UPSTREAM_FAILED to a Terminal Task Instance State instead of an Intermediate State. - Added REMOVED to the list of successful terminal task instance states. - Iterate programmatically through successful, failure, and in progress states instead of hard-coding. * update tests * Remove duplicate pointer to mwaatasksensor docs * merge #53000 * Fix integration tests * removed unnecessary defensive tests for trigger acceptor states after #53000 merge * removed unnecessary defensive tests for trigger acceptor states after #53000 merge * remove State file from PR * Remove hard coding deferrable property * Remove unnecessary execute_complete function in sensor and instead use end_from_trigger * Correctly use end_from_trigger attribute * Correctly use end_from_trigger attibute for both dag run sensor and task sensor * Remove unnecessary import
* Add MwaaTaskSensor to Amazon Provider Package * include pre-commit hooks * - Comply with PR apache#51196: explicitly pass to its superclass, and adjust the default value of in base class to . - Add defensive test around adding more task instance states to keep of the MwaaTaskCompletedTrigger up to date. - Fix issue where of the MwaaTaskSensor derives to instead of type. - Modify documentation to clearly indicate that the MwaaTaskSensor is meant to sense tasks across different MWAA environments. - Make an optional parameter, where it defaults to the latest dag run. - Externally fetch the task ID variable. - Test the sensor while a DAG Run is still in progress. * documentation update * Response to PR apache#51719 comments - Brought UPSTREAM_FAILED to a Terminal Task Instance State instead of an Intermediate State. - Added REMOVED to the list of successful terminal task instance states. - Iterate programmatically through successful, failure, and in progress states instead of hard-coding. * update tests * Remove duplicate pointer to mwaatasksensor docs * merge apache#53000 * Fix integration tests * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * remove State file from PR * Remove hard coding deferrable property * Remove unnecessary execute_complete function in sensor and instead use end_from_trigger * Correctly use end_from_trigger attribute * Correctly use end_from_trigger attibute for both dag run sensor and task sensor * Remove unnecessary import
* Add MwaaTaskSensor to Amazon Provider Package * include pre-commit hooks * - Comply with PR apache#51196: explicitly pass to its superclass, and adjust the default value of in base class to . - Add defensive test around adding more task instance states to keep of the MwaaTaskCompletedTrigger up to date. - Fix issue where of the MwaaTaskSensor derives to instead of type. - Modify documentation to clearly indicate that the MwaaTaskSensor is meant to sense tasks across different MWAA environments. - Make an optional parameter, where it defaults to the latest dag run. - Externally fetch the task ID variable. - Test the sensor while a DAG Run is still in progress. * documentation update * Response to PR apache#51719 comments - Brought UPSTREAM_FAILED to a Terminal Task Instance State instead of an Intermediate State. - Added REMOVED to the list of successful terminal task instance states. - Iterate programmatically through successful, failure, and in progress states instead of hard-coding. * update tests * Remove duplicate pointer to mwaatasksensor docs * merge apache#53000 * Fix integration tests * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * remove State file from PR * Remove hard coding deferrable property * Remove unnecessary execute_complete function in sensor and instead use end_from_trigger * Correctly use end_from_trigger attribute * Correctly use end_from_trigger attibute for both dag run sensor and task sensor * Remove unnecessary import
* Add MwaaTaskSensor to Amazon Provider Package * include pre-commit hooks * - Comply with PR apache#51196: explicitly pass to its superclass, and adjust the default value of in base class to . - Add defensive test around adding more task instance states to keep of the MwaaTaskCompletedTrigger up to date. - Fix issue where of the MwaaTaskSensor derives to instead of type. - Modify documentation to clearly indicate that the MwaaTaskSensor is meant to sense tasks across different MWAA environments. - Make an optional parameter, where it defaults to the latest dag run. - Externally fetch the task ID variable. - Test the sensor while a DAG Run is still in progress. * documentation update * Response to PR apache#51719 comments - Brought UPSTREAM_FAILED to a Terminal Task Instance State instead of an Intermediate State. - Added REMOVED to the list of successful terminal task instance states. - Iterate programmatically through successful, failure, and in progress states instead of hard-coding. * update tests * Remove duplicate pointer to mwaatasksensor docs * merge apache#53000 * Fix integration tests * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * removed unnecessary defensive tests for trigger acceptor states after apache#53000 merge * remove State file from PR * Remove hard coding deferrable property * Remove unnecessary execute_complete function in sensor and instead use end_from_trigger * Correctly use end_from_trigger attribute * Correctly use end_from_trigger attibute for both dag run sensor and task sensor * Remove unnecessary import
PR for #52999:
Move UPSTREAM_FAILED task instance state from intermediate to terminal state class and add tests to validate that state class relationships remain consistent (failed + success = terminal, terminal + intermediate = all task states).
Thoughts on this change? Motivated from #51719, @eladkal's comment:
Wanted to make this a separate PR for it since its scope it quite different.
Most likely this code will break some integration tests because there's various places that depend on the task instance states in interesting ways, but wanted to field feedback first before fixing them.