Repository navigation
Show error in UI when a DAG with same dag_id as another DAG is present - #17891
siddharthvp wants to merge 5 commits into
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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
There was a problem hiding this comment.
Using fileloc_hash here as that's an indexed column so should be faster to query, though this does necessitate computing the hash of the current dag's fileloc.
There was a problem hiding this comment.
I'm assuming that we don't actually want to re-parse that other file to see if the same-id-DAG is still present.
If the two DAGs have the same number and IDs of tasks, the error is suppressed as it's possible it's the same DAG just moved from one file to another. This is awful - is there a better heuristic we can use?
There was a problem hiding this comment.
If it was just a file rename, it would go away on the next scan, right? Can we pend the error immediately but only show it to the user if it is still the case later on?
|
This logic feels hacky to me. Even if the numbers of tasks are not the same, we can’t be sure it’s a duplicated ID either; the user might have renamed the file and made some modification. I think this is theoratically impossible to fix in the current structure. To really resolve this, we need a place to actually aggregate all the known DAG IDs during a DAG-parsing run. One possibility is to implement something like a standalone process exposing a message queue for every DAG-parsing process to send parsed DAG IDs to, and raises an error if it seems duplication. Another possibility is, instead of storing parsed DAGs directly to Both would require some pretty involved change though. |
|
Yes the logic is indeed hacky. @uranusjr Even with the two solutions you suggest, the problem doesn't really go away (unless I'm much mistaken) - if a DAG is moved from one file to another in the middle of a parsing run and Airflow processed the source file before the move occurred and the destination file after the move, we still have a false-positive error. So I think the only way to implement this feature would be via hacky heuristics. Maybe we should also change the exception text to clarify that it is a possible duplication. When the next DAG parsing run occurs, the false-positive alert would disappear. |
There was a problem hiding this comment.
If these two lists are built from the same DAG, will they always be in the same order? If not then the comparison isn't going to be accurate.
If they aren't in a deterministic order, maybe we could sort or cast to a set before comparison?
While the exception (`AirflowDagDuplicatedIdException`) already existed, till now it was being raised only when both the DAGs with same ID were in the same file. Closes apache#17861.
Co-authored-by: Ephraim Anierobi <[email protected]>
f672832 to
f1d44f9
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
While the exception (
AirflowDagDuplicatedIdException) alreadyexisted, till now it was being raised only when both the DAGs with
same ID were in the same file.
Closes #17861.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.