bramhanandlingala opened a new pull request, #67431: URL: https://github.com/apache/airflow/pull/67431
## Problem When a DAG bundle is removed from dag_bundle_config_list, sync_bundles_to_db logs "DAG bundle X is no longer found in config and has been disabled" and correctly sets bundle.active = False, but it never updates the associated DagModel rows to is_stale = True. As a result, the removed bundle's DAGs remain visible in the UI as functional workflows. ## Root cause In DagBundlesManager.sync_bundles_to_db (airflow-core/src/airflow/dag_processing/bundles/manager.py), the loop that handles bundles absent from config only sets bundle.active = False and cleans up import errors. There is no statement to flip DagModel.is_stale. ## Changes airflow-core/src/airflow/dag_processing/bundles/manager.py # Added update to the sqlalchemy import. Added a local import of DagModel (alongside the existing ParseImportError local import, to avoid circular imports). After marking a bundle inactive, execute a bulk UPDATE dag SET is_stale = true WHERE bundle_name = <name>. airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py # Updated the clear_db fixture to also clear DagModel rows before/after tests. Added test_sync_bundles_to_db_marks_dags_stale_on_bundle_removal, creates a bundle, adds a non-stale DAG for it, removes the bundle from config, and asserts dag.is_stale is True. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
