-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Refactor: remove unused state - SHUTDOWN #33746
Conversation
This state is never set in production code, so it may as well be deprecated.
I found out about it when I was troubleshooting another issue. A task state is never set to SHUTDOWN except for tests. I think originally this state was supposed to handle tasks that were running but were externally cleared (what is currently handled by RESTARTING). Apparently the author of that change (#16681) mistakenly assumed that this state is used for tasks externally marked as failed. In reality, when marking a task externally as failed, webserver sets it directly to FAILED state, as can be verified by code inspection. |
I would also like to update the diagram that was updated last time here: |
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.
Unfortunately removing a state from the classes State, JobState or TaskInstanceState is a breaking change.
@hussein-awala |
Are you sure there are no users that have a "shutdown" state in their DB and would like to see that task displayed in the UI ? Airflow users have also historical database with historical tasks status. My question is here - did you consider the case that somene has such task in the database? what will happen there? I am not saying it is wrong to remove it, I am just asking if you considered it and and thought about the historical data affecting the current code.
I think answer to those questions is important when you decide to remove something. It is easy to say "I remove something because it is not used". But in case "it was used" - you need to have analysed what impact it has. Can you please answer the above questions @Bisk1 ? |
@potiuk I understand the concerns about historical state, I'll try to answer your questions and make a case why is it safe to ignore it.
I would also like to mention that I made this change because the current description of states makes it difficult to understand the code. The description doesn't reflect reality, so I've spend a couple of days debugging Airflow trying to pinpoint my issue because of tech debt like this. Cleaning it up would be beneficial for future maintainers who would have easier time contributing. |
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.
Cool. Thanks for so thorough analysis @Bisk1 . Really helpful.
I think the API call given 500 is quite worrying though. The task is there and someone could have written an automation that analyses past tasks - and for example builds some kinds of dashboard out ot that.
The REST API of ours is explicitly part of our public API interface (https://airflow.apache.org/docs/apache-airflow/stable/public-airflow-interface.html) so it's not only UI users that are of our concern. Airflow is a platform that our users can extend, and REST API is a crucial component for that.
I believe we should keep the API working and returning information about the task in such state if someone has it in the DB.
A lot of our users have old versions of airlfow (for various reasons), so I expect that we might want to get someone upgrading from 2.1.4 to 2.7.0 directly and those (potential) "shutdown" tasks will be quite recent ones. This might break the automation users might have. We would like to avoid that.
It should be possible by slightly modifying API to include the "shutdown" state in it "extra" and add comment about why we are doing it in the code even it the enum is removed.
I think that would be a better solution.
Also - there was a bit differnt story with Smart Sensors - they were an "experimental" feature. Anyone using them SHOULD expect that it might change and break things - it's been announced as having "experimental" status when it was added so users using it really signed up for changes and removal of it from the API is not covered by our SemVer promises. |
@potiuk I was trying to follow your suggestion and wanted to modify API to have special handling for airflow/airflow/api_connexion/openapi/v1.yaml Lines 4684 to 4697 in f9276f0
I did my test with querying a Do you think I should fix it and add |
I used good ol' Paint because couldn't find the original .drawio file
Ah.. cool then. No. Of course there i sno need to ADD it back. It would only make sense if the API had ever had it. I looked back to the very beginning and it had never been there. In this case - I am pretty good. |
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.
Pending CI
Looks like we have confirmation it looks safe to remove @hussein-awala . Still "requesting changes? ? |
This requires also documentation update |
|
Looks like we should add a significant news fragment for this @Bisk1 |
@ephraimbuddy -> I am not so sure. Look at the discussion . It's really a cleanup. SHUTDOWN had not been used for years (effectively removed in Airflow 2.2 released 2 years ago) . It has not been even properly (ever) handled in the API (500 error). It's really a cleanup and if anything it COULD be added to 2.2.0 release note's "shoutouts" as afterthought. |
We need to add By removing this as we have done this caused import errors. One such use I know of is https://github.com/astronomer/astro-sdk/blob/75838143c1b3181b636259e5c39fa27a70d89c3c/python-sdk/src/astro/sql/operators/cleanup.py#L167 (This showed up as a DAG parse error on our tests against Airflow main) |
Is |
Good point. We should also add "airflow.utils.state" to the https://airflow.apache.org/docs/apache-airflow/stable/public-airflow-interface.html as this is something that other users might rely on. It's been enum and it's been released in the past and we need to keep it backwards-compatible. |
Added PR #34059 |
The state enums are likely to be used externally and they should not be changed in backwards-incompatible way. Discussed in apache#33746
Co-authored-by: daniel.dylag <[email protected]> (cherry picked from commit 7faa727)
This state is never set in production code, so it may as well be deprecated. Also it is not part of API spec.
Updated test cases to use FAILED or RESTARTING as relevant.
^ 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.