Repository navigation
Warn when Dag bundles are configured with the same source - #77375
basantjamwal wants to merge 3 commits into
Conversation
|
Good addition. Complementing the collection guard in #76556, caught three edge cases:
Opened a PR against your branch with these fixes and tests: basantjamwal#1 Merging it will update this PR automatically. |
|
Thanks @meel-ayush, I went through basantjamwal#1. I'll take (3) and move the manager tests into core's |
|
Agreed on (1), dropped the connection lookup to keep config parsing strictly in-memory. Moved the manager tests into core's Updated basantjamwal#1 so you can merge it directly. |
Resolve connection IDs and case-insensitive paths in bundle source keys
|
Thanks @meel-ayush, merged basantjamwal#1. Agreed on keeping config parsing in-memory, so the connection lookup stays out. The manager tests now live in core's |
closes: #77241
DagBundlesManager.parse_configidentifies bundles only byname, so two bundles that read thesame files (for example one Git repository over SSH and over HTTPS) are accepted without any
warning. Every file is then parsed twice, import errors are reported twice, and Dag ownership
switches between the two bundles on each parse loop.
This adds detection at config-parse time, as a warning only.
Changes
BaseDagBundle.source_key(**kwargs): new optional classmethod that says where a bundle readsits files from. It returns
Noneby default, so existing and third-party bundles are unaffected.LocalDagBundlereturns its resolved directory.GitDagBundlereturns the repository (ashost/path, without user, port or.git), thetracking ref and the subdir. SSH and HTTPS URLs of one repository give the same key. When
repo_urlis not in the kwargs (it comes from the connection) or is a local path, the keyis
Noneand the bundle is not compared.DagBundlesManagerlogs one warning naming the bundles that share a source. The hook iscalled through
getattrand wrapped intry/except, so an older provider or a faulty hookcannot break config parsing.
dag-bundles.rstand a line in the duplicatedag_idFAQ entry.Reproduction (before)
Two
LocalDagBundles pointing at the same folder, on theapache/airflowDocker image: bothload without a warning, both parse the same files, and
Duplicate dag_id detectedalternatesexisting_bundle=a/bevery parse loop. A broken file is listed twice inairflow dags list-import-errors.Tests
test_local.py: key equal for equivalent paths, different for another path.test_git.py: SSH,ssh://, HTTPS and HTTPS-with-credentials URLs give the same key; a different repository, ref or subdir gives a different key; no key without a remote URL; two end-to-endDagBundlesManagertests (warns for SSH + HTTPS of one repository, silent for different repositories).test_local.py,test_git.py(new tests) andtest_dag_bundle_manager.pylocally, plusruff checkandruff format.Left out on purpose
reject_duplicate_bundle_sourcesoption that turns the warning into an error (new config option, separate decision).subdir=""andsubdir="dags"), which can be intentional.The warning is logged each time
DagBundlesManagerparses the config, so it appears in the log of each component that loads it.URL test cases were informed by #77313 by @bnspopi, who offered them.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude following the guidelines