Fix #60763: Deactivate legacy DAGs with NULL bundle_name during upgrade from 2.x to 3.x#61019
Conversation
SameerMesiah97
left a comment
There was a problem hiding this comment.
It’s great that you identified the issue but I am not sure if this is the right fix.
|
I am not sure that this approach is correct, maybe instead it should be a db migrations script rather than a change in the query? |
ee0fb5f to
0253b5c
Compare
|
Updated the PR based on feedback from @SameerMesiah97, @uranusjr, and @Nataneljpwd. Replaced the query change with migration The original @uranusjr — targeting |
049043a to
25b43b5
Compare
Nataneljpwd
left a comment
There was a problem hiding this comment.
Looks good, but this will only fix an upgrade from 2.x to 3.2, I wonder if this can be backported
|
@Nataneljpwd — v3-1-test already has migration 0082_3_1_0_make_bundle_name_not_nullable.py which covers this fix for 3.1.x users. This PR targets main (3.2.x) for users upgrading directly from 2.x to 3.2 who would miss that migration. |
As long as it is made clear, great! |
Nataneljpwd
left a comment
There was a problem hiding this comment.
Looks good to me!
Thank you for the fix!
25b43b5 to
0a54fc9
Compare
bb94d4e to
808f7d9
Compare
c9997a0 to
c18e8f5
Compare
|
@kalluripradeep A few things need addressing before review — see our Pull Request quality criteria.
No rush. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
CI issue fixed and all the checks are now running as expected |
a5fc24c to
4cf1e1a
Compare
|
To me introducing a new migration for a edge case is not right. I prefer query based approch. WDYT @jedcunningham @uranusjr ? |
4cf1e1a to
b35d533
Compare
… upgrade from 2.x to 3.x This uses a query-based approach to deactivate legacy DAGs with NULL bundle_name, avoiding the need for a database migration that caused CI failures and addressing maintainer feedback.
7b209b1 to
88b8171
Compare
|
@jedcunningham @uranusjr — @vatsrahul1001 asked your take on the query-vs-migration approach for this 3-line Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
|
@kalluripradeep — This PR is labeled ready for maintainer review, and a maintainer left feedback about 7 days ago that is still awaiting your response. Could you take a look and either push an update or reply in the thread? Once you have responded, a maintainer will pick it back up from the review queue. No rush — just flagging it so the PR does not stall. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
| # the processor has stopped parsing their files, so the time-based check below would never fire. | ||
| if dag.bundle_name in inactive_bundles: | ||
| # Legacy DAGs with a NULL bundle_name (e.g. from Airflow 2.x) are also stale, as they will never be parsed. | ||
| if dag.bundle_name is None or dag.bundle_name in inactive_bundles: |
There was a problem hiding this comment.
Won't the bundle name be fixed for null bundle_name after some times? Can you verify it
There was a problem hiding this comment.
The bundle_name is updated during parsing when the DAG processor reads the DAG files for a bundle (setting it to the name of the bundle, e.g., 'dags-folder').
However, in the upgrade scenario described in #60763, legacy DAGs are removed/deleted at the same time as the upgrade. Because their source files are gone, the DAG processor will never parse them again, and they will never have their bundle_name updated—it will remain None/NULL in the database forever.
Since their bundle_name remains None, they are never identified as stale under active bundles and thus are never deactivated, causing them to persist in the UI indefinitely. The query change ensures these legacy, deleted DAGs are caught and deactivated.
There was a problem hiding this comment.
Can you expand the in-code comment a bit? The context you provided is critical to understand why the check is needed, but the current wording fails to capture it.
|
I have updated the PR title and description to align with the query-based approach (removing references to the database migration) as suggested. The implementation in |
Fixes #60763
What changed
Replaced the migration-based fix with a query-based check, based on feedback from @vatsrahul1001, @uranusjr, and @SameerMesiah97.
Problem
When upgrading from Airflow 2.x to 3.x, legacy DAGs retain
bundle_name = NULL. The deactivation logic indeactivate_stale_dags()queries bybundle_name.in_(bundle_names)(where active/inactive bundles are checked), which excludes NULL values — so removed legacy DAGs are never deactivated.Solution
Updated
manager.pyto treat legacy DAGs with a NULLbundle_nameas stale/inactive: ifdag.bundle_nameisNoneor ininactive_bundles, deactivate it immediately.Important
🛠️ Maintainer triage note for @kalluripradeep · by
@potiuk· 2026-07-02 17:46 UTCSome review feedback from
@ephraimbuddyis waiting on you:@ephraimbuddyneed a reply or a fix.The ball is in your court — you've been assigned to this PR. Reply or push a fix in each thread, then mark them resolved.
Automated triage — may be imperfect; a maintainer takes the next look.