Skip to content
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

AIP-72: Handling failed TI state for AirflowFailException & AirflowSensorTimeout #44954

Merged
merged 10 commits into from
Dec 18, 2024

Conversation

amoghrajesh
Copy link
Contributor

related: #44414

We already have support for handling terminal states from the task execution side as well as the task SDK client side. (almost) and failed state is part of the terminal state.

This PR extends the task runner's run function to handle cases when we have to fail a task: AirflowFailException, AirflowSensorTimeout. It is functionally very similar to #44786

As part of failing a task, multiple other things also needs to be done like:

Testing performed

End to End with Postman

  1. Run airflow with breeze and run any DAG
    image

  2. Login to metadata DB and get the "id" for your task instance from TI table
    image

  3. Send a request to fail your task
    image

Or using curl:

curl --location --request PATCH 'http://localhost:29091/execution/task-instances/0193cec2-f46b-7348-9c27-9869d835dc7b/state' \
--header 'Content-Type: application/json' \
--data '{
    "state": "failed",
    "end_date": "2024-10-31T12:00:00Z"
}'
  1. Refresh back the Airflow UI to see that the task is in failed state.
    image

^ 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.

@amoghrajesh amoghrajesh changed the title Aip72 failexception AIP-72: Handling failed TI state for AirflowFailException & AirflowSensorTimeout Dec 16, 2024
@amoghrajesh amoghrajesh self-assigned this Dec 16, 2024
@amoghrajesh amoghrajesh changed the title AIP-72: Handling failed TI state for AirflowFailException & AirflowSensorTimeout AIP-72: Handling failed TI state for AirflowFailException & AirflowSensorTimeout Dec 17, 2024
Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On high-level it lgtm -- although please address the comments I had

@amoghrajesh
Copy link
Contributor Author

@kaxil I will merge this PR once the CI is green to unblock the other PRs which are based on this branch

@kaxil kaxil merged commit cfc2157 into apache:main Dec 18, 2024
50 checks passed
@kaxil kaxil deleted the AIP72-failexception branch December 18, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants