Repository navigation
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
fbdca7e to
7cfe224
Compare
|
It looks to me this relies on the directory content following certain conventions that did not previously exist. This is a problem on its own, but it means descriptions must be added to the documentation in relevant sections. |
There was a problem hiding this comment.
Pull request overview
Adds support for dynamically loading DAG bundle configuration from a directory of JSON files (with change detection), enabling hot-reload behavior in the DAG processor without requiring restarts.
Changes:
- Add
dag_bundle_config_pathconfig option and JSON-directory parsing logic toDagBundlesManager - Add config-path change detection + bundle cleanup/reload flow in
DagFileProcessorManager - Make
ParseImportError.full_file_path()resilient when a referenced bundle has been removed
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py | Adds unit tests for config-path parsing, precedence, change detection, and safe bundle accessors |
| airflow-core/src/airflow/models/errors.py | Avoids raising when a bundle referenced by an import error has been removed |
| airflow-core/src/airflow/dag_processing/manager.py | Reuses a bundles manager and triggers reload/cleanup when config-path changes |
| airflow-core/src/airflow/dag_processing/bundles/manager.py | Implements config-path parsing, mtime tracking, and “safe” bundle access methods |
| airflow-core/src/airflow/config_templates/config.yml | Documents new dag_bundle_config_path setting |
@uranusjr |
Adds a new `dag_bundle_config_path` setting that allows loading DAG bundle configurations from JSON files in a directory. This enables hot-reloading of bundle configurations without restarting the DAG processor, which is particularly useful in Kubernetes environments where ConfigMaps can be mounted as files. When `dag_bundle_config_path` is set, it takes precedence over the existing `dag_bundle_config_list` setting. The DAG processor monitors the directory for file additions, removals, and modifications, and automatically reloads bundles when changes are detected. Key changes: - DagBundlesManager: new _parse_config_from_path(), check_config_path_changes(), and get_bundle_path_safe() methods - DagFileProcessorManager: reuses a single DagBundlesManager instance and detects config path changes in the refresh loop, cleaning up removed bundles - ParseImportError: graceful handling when bundles are removed - config.yml: new dag_bundle_config_path option
Rename loop variable to avoid shadowing Path-typed file_path with str-typed iteration variable from dict.items().
…nges The check_config_path_changes() call in _refresh_dag_bundles() must use `is True` identity check rather than truthiness, because MagicMock returns a truthy MagicMock object by default. Also restore sync_bundles() and get_all_bundles() to use throwaway DagBundlesManager instances (matching upstream pattern) to avoid mock interference.
Adds a prose section to dag-bundles.rst describing the directory convention, JSON file format, hot-reload semantics, precedence over dag_bundle_config_list, and validation behaviour for the new dag_bundle_config_path option (the previous PR commits only added a config.yml description). Also addresses review correctness/robustness feedback on the DagBundlesManager directory mode: - Track every *.json file's mtime regardless of parse outcome, so invalid or duplicate-name files no longer cause check_config_path_changes to report "changed" on every poll. - Use st_mtime_ns instead of float st_mtime for reliable detection on filesystems with coarse-resolution timestamps. - Validate that the JSON "name" is a non-empty string before adding it to the duplicate-detection set; non-string names previously raised TypeError when added to a set. - Clear bundle_config and config_path_mtime on the early-return paths (missing directory, no valid configs found) so removed bundles get cleaned up instead of staying configured. - Replace time.sleep(0.01) in the test with an explicit os.utime mtime bump so the test doesn't depend on filesystem timestamp granularity.
368bfa5 to
8abfb21
Compare
|
Note 🗑️ Closing stale draft · by This draft has been inactive for ~14 days. Closing to keep the queue tidy — no judgment on the change itself. Please reopen (or open a fresh PR) whenever you pick it back up, and a maintainer will be glad to take a look. Automated triage — may be imperfect. |
|
Please take over. |
Add a new
dag_bundle_config_pathsetting that allows loading DAG bundle configurations from JSON files in a directory, enabling hot-reloading without restarting the DAG processor.Motivation: In Kubernetes environments, bundle configurations need to change frequently (e.g., via ConfigMaps). The current
dag_bundle_config_listrequires static config inairflow.cfgand a processor restart. This feature allows mounting a directory of JSON files and having the DAG processor automatically detect and apply changes.Key changes:
DagBundlesManager: new_parse_config_from_path(),check_config_path_changes(), andget_bundle_path_safe()methodsDagFileProcessorManager: reuses a singleDagBundlesManagerinstance; detects config path changes in the refresh loop, cleaning up removed bundles (processors, file stats, DAGs)ParseImportError.full_file_path(): graceful handling when bundles are removedconfig.yml: newdag_bundle_config_pathoption under[dag_processor]JSON config format:
{ "name": "my-git-repo", "classpath": "airflow.providers.git.bundles.git.GitDagBundle", "kwargs": { "tracking_ref": "main", "git_conn_id": "my_git_conn" } }Behavior:
dag_bundle_config_pathis set, it takes precedence overdag_bundle_config_listWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.6) following the guidelines
Important
🛠️ Maintainer triage note for @tardunge · by
@potiuk· 2026-06-17 14:51 UTCHelpful heads-up from the maintainers — please address before this PR can be reviewed:
CI image checks / Build documentation (--spellcheck-only)). Run them locally withprek run --all-files(orpre-commit run --all-files) and push the fixes.provider distributions tests / Compat 2.11.1:P3.10:,provider distributions tests / Compat 3.0.6:P3.10:,provider distributions tests / Compat 3.1.8:P3.10:,provider distributions tests / Compat 3.2.1:P3.10:. Reproduce and fix locally, then push.The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.
Automated triage — may be imperfect; a maintainer takes the next look.