Skip to content

Keep ZIP-archived Dags active when dag_discovery_safe_mode is False#68518

Open
Vamsi-klu wants to merge 1 commit into
apache:mainfrom
Vamsi-klu:fix-dag-discovery-safe-mode-zip-66104
Open

Keep ZIP-archived Dags active when dag_discovery_safe_mode is False#68518
Vamsi-klu wants to merge 1 commit into
apache:mainfrom
Vamsi-klu:fix-dag-discovery-safe-mode-zip-66104

Conversation

@Vamsi-klu

Copy link
Copy Markdown
Contributor

Fixes #66104.

When [core] dag_discovery_safe_mode is False, Dags defined in ZIP archives whose source does not contain the airflow/dag keywords were parsed and activated by the Dag file processor but then immediately deactivated on the next scan. _get_observed_filelocs expanded ZIP members with a hardcoded safe_mode=True, so keyword-less members were absent from the observed set and deactivate_deleted_dags marked them stale.

Changes:

  • Resolve dag_discovery_safe_mode once on DagFileProcessorManager and use it for both file discovery (_find_files_in_bundle) and the observed-filelocs scan (_get_observed_filelocs), fixing the hardcoded True.
  • Log the effective dag_discovery_safe_mode per bundle. In separate-process deployments (Helm/OpenShift) the flag must be set on the dag-processor and the component restarted; otherwise Dags appear after airflow dags reserialize and disappear on the next scan (the plain-.py symptom in the issue). The log makes that misconfiguration diagnosable.
  • Clarify the config.yml / docs guidance accordingly.

Tested: new parametrized regression test test_get_observed_filelocs_respects_dag_discovery_safe_mode (keyword-less ZIP member is observed when safe_mode is False, filtered when True).


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

The Dag file processor parsed and activated keyword-less Dags inside ZIP
archives but then immediately deactivated them, because the scan that
decides which files still exist ignored dag_discovery_safe_mode and always
applied the airflow/dag keyword heuristic. Resolve the setting once and use
it consistently for discovery and the deactivation scan, and log the
effective value so a misconfigured processor is diagnosable.

closes: apache#66104
@Vamsi-klu Vamsi-klu force-pushed the fix-dag-discovery-safe-mode-zip-66104 branch from 11741f4 to 942843f Compare June 14, 2026 02:24
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.

`dag_discovery_safe_mode not scanning all files when set to False

1 participant