Skip to content

Add dynamic DAG bundle configuration from file path - #71111

Open
judahrand wants to merge 4 commits into
apache:mainfrom
judahrand:feature/dynamic-dag-bundle-config
Open

Add dynamic DAG bundle configuration from file path#71111
judahrand wants to merge 4 commits into
apache:mainfrom
judahrand:feature/dynamic-dag-bundle-config

Conversation

@judahrand

@judahrand judahrand commented Aug 4, 2026

Copy link
Copy Markdown

This PR picks up where #63928 left off.

closes: #59799 #60859 #66858


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

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


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg

boring-cyborg Bot commented Aug 4, 2026

Copy link
Copy Markdown

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
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@judahrand
judahrand force-pushed the feature/dynamic-dag-bundle-config branch from 8abfb21 to 02da222 Compare August 4, 2026 17:09
@judahrand judahrand changed the title Feature/dynamic dag bundle config Add dynamic DAG bundle configuration from file path Aug 4, 2026
@judahrand
judahrand marked this pull request as ready for review August 4, 2026 17:21
@judahrand
judahrand force-pushed the feature/dynamic-dag-bundle-config branch from 02da222 to 34c19ff Compare August 4, 2026 17:38
TARDUNGE and others added 4 commits August 6, 2026 09:20
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.
@judahrand
judahrand force-pushed the feature/dynamic-dag-bundle-config branch from 34c19ff to cc41051 Compare August 6, 2026 08:20
@judahrand

Copy link
Copy Markdown
Author

Pinging for review after 72hrs: @ashb @XD-DENG @ephraimbuddy @jedcunningham

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.

1 participant