Repository navigation
Conversation
DagBundlesManager keys bundles by name and never compares where they read their files from. The same Git repository, branch and subdir configured twice, once with an SSH URL and once with an HTTPS URL, was accepted as two bundles: every file was parsed twice, import errors were reported twice, and each Dag kept moving from one bundle to the other. Bundles can now say where they read from through a source_key() classmethod on BaseDagBundle, which returns None by default. The manager logs a warning when two configured bundles return the same key. LocalDagBundle returns its resolved directory. GitDagBundle returns the repository as host/path (without user, port or .git, so SSH and HTTPS URLs compare equal) together with the tracking ref and the subdir. When the repository URL comes from the connection, the key is not known at this point and the bundle is not compared. The docs now say that two bundles must not read the same source. related: apache#77241 Co-Authored-By: Claude Fable 5.2 <[email protected]>
Contributor
|
Hi @bnspopi, thanks for the heads-up, and for tagging me. I'd reproduced this and posted the root cause and plan on #77241, and I'm already working on my own PR, which I'll raise shortly. Since you mentioned you'd be happy to close yours if mine is in progress, I'd really appreciate that. Thanks for understanding! |
Contributor
Author
|
Thanks @basantjamwal, and no problem. I will leave this as a draft for now so the fix is not lost, and close it as soon as your PR is up. If anything here is useful for yours (the URL normalisation or the test cases), feel free to take it. |
1 task done
Contributor
Contributor
Author
|
Thanks @basantjamwal. Closing this in favour of #77375 as promised, and thanks for the credit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DagBundlesManager.parse_configkeys bundles by name and never compares where they read their files from. If the same Git repository, branch and subdir is configured twice, once with an SSH URL and once with an HTTPS URL, Airflow accepts both as independent bundles. The Dag processor then clones and parses everything twice, every import error is reported twice, and each Dag keeps moving from one bundle to the other. That is what #77241 reports.This adds the detection described in the issue, as a warning only:
BaseDagBundle.source_key(**kwargs)is a new classmethod that says where a bundle with those kwargs reads from. It returnsNoneby default, which means "not known", so existing and third-party bundles are unaffected.LocalDagBundlereturns its resolved directory.GitDagBundlereturns the repository ashost/pathtogether with the tracking ref and the subdir. The user, port and.gitsuffix are dropped and the host is lower-cased, so[email protected]:org/repo.git,ssh://[email protected]:22/org/repo.gitandhttps://[email protected]/org/repogive the same key. Whenrepo_urlis not in the kwargs (it comes from the connection) or is a local path, the key isNoneand the bundle is not compared.DagBundlesManager.parse_configlogs a warning naming the bundles that share a key.dag-bundles.rstand the duplicate dag id FAQ entry now say that two bundles must not read the same source.Left out on purpose:
[dag_processor] reject_duplicate_bundle_sourcesflag that would turn the warning into an error. It is a new config option and a separate decision.subdir=""andsubdir="dags"). The issue notes this can be intentional.DagBundlesManagerparses the config, so it appears in the log of each component that loads the bundle configuration.@basantjamwal proposed this same plan in the issue. I am happy to close this in favour of their PR if they already have one in progress.
Tests, run on Linux with SQLite:
test_dag_bundle_manager.py,test_local.py,test_base.py: 107 passed (5 new cases).providers/git/tests/unit/git/bundles/test_git.py: 142 passed (11 new cases).related: #77241
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
🤖 Generated with Claude Code