Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Model it already exists (duplicate model sync owing to multiple parent dependencies) #275

Open
jo-bzh opened this issue Jul 5, 2024 · 0 comments

Comments

@jo-bzh
Copy link

jo-bzh commented Jul 5, 2024

Environment

  • DiffSync version: 2.0.0
  • Python version 3.12

Observed Behavior

When launch sync_from function for a dataset with multiple model dependencies, in this example Regions parent of Sites. sync_from by default try to create Sites (child object) several times for each dependencies as you can see below.

2024-07-05 16:59:05,401 - DEBUG - 2024-07-05 14:59.05 [debug    ] Diff calculation between these two datasets will involve 17 models [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> src=<NetboxAdapter "netbox">
2024-07-05 16:59:05,401 - INFO - 2024-07-05 14:59.05 [info     ] Beginning diff calculation     [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> src=<NetboxAdapter "netbox">
2024-07-05 16:59:05,402 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Seclin
2024-07-05 16:59:05,402 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Vendome
2024-07-05 16:59:05,402 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Rennes
2024-07-05 16:59:05,404 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=SCATEST
2024-07-05 16:59:05,404 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=SCLTEST
2024-07-05 16:59:05,405 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Vendome
2024-07-05 16:59:05,405 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Belgium
2024-07-05 16:59:05,405 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=brussels
2024-07-05 16:59:05,406 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=SCATEST
2024-07-05 16:59:05,406 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=SCLTEST
2024-07-05 16:59:05,407 - DEBUG - 2024-07-05 14:59.05 [debug    ] Skipping due to SKIP_UNMATCHED_DST flag on source adapter [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=VDMTEST
2024-07-05 16:59:05,407 - INFO - 2024-07-05 14:59.05 [info     ] Diff calculation complete      [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> src=<NetboxAdapter "netbox">
2024-07-05 16:59:05,408 - INFO - 2024-07-05 14:59.05 [info     ] Beginning sync                 [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> src=<NetboxAdapter "netbox">
2024-07-05 16:59:05,408 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model update        [diffsync.helpers] action=update diffs={'-': {'slug': 'courbevoie'}, '+': {'slug': 'courbevois'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=Courbevoie
2024-07-05 16:59:05,409 - INFO - 2024-07-05 14:59.05 [info     ] Updated successfully           [diffsync.helpers] action=update diffs={'-': {'slug': 'courbevoie'}, '+': {'slug': 'courbevois'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> status=success unique_id=Courbevoie
2024-07-05 16:59:05,409 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model update        [diffsync.helpers] action=update diffs={'-': {'parent': 'France'}, '+': {'parent': 'france'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Rennes
2024-07-05 16:59:05,409 - INFO - 2024-07-05 14:59.05 [info     ] Updated successfully           [diffsync.helpers] action=update diffs={'-': {'parent': 'France'}, '+': {'parent': 'france'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> status=success unique_id=Rennes
2024-07-05 16:59:05,409 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model create        [diffsync.helpers] action=create diffs={'+': {'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=BOB
2024-07-05 16:59:05,427 - INFO - Created Site in YML file: {'name': 'BOB', 'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}
2024-07-05 16:59:05,428 - INFO - 2024-07-05 14:59.05 [info     ]                                [diffsync.helpers] action=create diffs={'+': {'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> status=success unique_id=BOB
2024-07-05 16:59:05,429 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model update        [diffsync.helpers] action=update diffs={'-': {'parent': 'France'}, '+': {'parent': 'france'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> unique_id=Seclin
2024-07-05 16:59:05,429 - INFO - 2024-07-05 14:59.05 [info     ] Updated successfully           [diffsync.helpers] action=update diffs={'-': {'parent': 'France'}, '+': {'parent': 'france'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=region src=<NetboxAdapter "netbox"> status=success unique_id=Seclin
2024-07-05 16:59:05,429 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model create        [diffsync.helpers] action=create diffs={'+': {'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=BOB
2024-07-05 16:59:05,430 - ERROR - 2024-07-05 14:59.05 [error    ] Failed to create site {'name': 'BOB'} - it already exists! [diffsync.helpers] action=create diffs={'+': {'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> status=error unique_id=BOB
2024-07-05 16:59:05,430 - WARNING - 2024-07-05 14:59.05 [warning  ] No object resulted from sync, will not process child objects. [diffsync.helpers] action=create diffs={'+': {'slug': 'bob', 'status': 'Staging', 'region': 'Rennes'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=BOB
2024-07-05 16:59:05,430 - DEBUG - 2024-07-05 14:59.05 [debug    ] Attempting model update        [diffsync.helpers] action=update diffs={'-': {'slug': 'courbevoie'}, '+': {'slug': 'courbevois'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> unique_id=Courbevoie
2024-07-05 16:59:05,430 - INFO - 2024-07-05 14:59.05 [info     ] Updated successfully           [diffsync.helpers] action=update diffs={'-': {'slug': 'courbevoie'}, '+': {'slug': 'courbevois'}} dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> model=site src=<NetboxAdapter "netbox"> status=success unique_id=Courbevoie
2024-07-05 16:59:05,430 - INFO - 2024-07-05 14:59.05 [info     ] Sync complete                  [diffsync.helpers] dst=<Local "local"> flags=<DiffSyncFlags.CONTINUE_ON_FAILURE|SKIP_UNMATCHED_DST: 5> src=<NetboxAdapter "netbox">

It try here to create BOB site and it created it bind to Rennes regions but after finish child sync of Rennes it try a second time to create BOB it self because in site list, and this raise a duplication error.

Expected Behavior

It should create once any objects even if it try to sync it in the child tree process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant