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

ACI Attempts to remove device types added by other fabrics #685

Open
kingfetty opened this issue Jan 28, 2025 · 0 comments
Open

ACI Attempts to remove device types added by other fabrics #685

kingfetty opened this issue Jan 28, 2025 · 0 comments
Labels
type: bug Issues/PRs addressing a bug.

Comments

@kingfetty
Copy link
Contributor

Environment

  • Python version: 3.11
  • Nautobot version: 2.4.1
  • nautobot-ssot version: 3.4.0

Expected Behavior

The expectation is the ability to use the SSoT ACI app to sync with multiple ACI fabrics.

{ "exc_message": [ "Cannot delete some instances of model 'DeviceType' because they are referenced through protected foreign keys: 'Device.device_type'.", [ { "__nautobot_type__": "nautobot.dcim.models.devices.Device", "display": "A", "id": "d9acf8d9-6b21-419d-b1c9-3d1c4f3071f0" }, { "__nautobot_type__": "nautobot.dcim.models.devices.Device", "display": "B", "id": "cc1bc0e7-e688-4051-b07b-a671c4286540" }, { "__nautobot_type__": "nautobot.dcim.models.devices.Device", "display": "C", "id": "ee33d4ac-8bcb-4e80-80d0-827bcff1a42b" }, { "__nautobot_type__": "nautobot.dcim.models.devices.Device", "display": "D", "id": "d3558227-4054-4c2c-af85-6904f1e5ce91" } ] ], "exc_module": "django.db.models.deletion", "exc_type": "ProtectedError" }

Traceback (most recent call last): File "/opt/nautobot/lib/python3.11/site-packages/celery/app/trace.py", line 477, in trace_task R = retval = fun(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/celery/app/trace.py", line 760, in __protected_call__ return self.run(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/nautobot/extras/jobs.py", line 1234, in run_job result = job(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/nautobot/extras/jobs.py", line 160, in __call__ return self.run(*args, **deserialized_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/nautobot_ssot/integrations/aci/jobs.py", line 105, in run super().run(dryrun=self.dryrun, memory_profiling=self.memory_profiling, *args, **kwargs) File "/opt/nautobot/lib/python3.11/site-packages/nautobot_ssot/jobs/base.py", line 354, in run self.sync_data(memory_profiling) File "/opt/nautobot/lib/python3.11/site-packages/nautobot_ssot/jobs/base.py", line 196, in sync_data self.execute_sync() File "/opt/nautobot/lib/python3.11/site-packages/nautobot_ssot/jobs/base.py", line 98, in execute_sync self.source_adapter.sync_to(self.target_adapter, flags=self.diffsync_flags) File "/opt/nautobot/lib/python3.11/site-packages/diffsync/__init__.py", line 626, in sync_to return target.sync_from(self, diff_class=diff_class, flags=flags, callback=callback, diff=diff) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/diffsync/__init__.py", line 598, in sync_from result = syncer.perform_sync() ^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/diffsync/helpers.py", line 329, in perform_sync changed |= self.sync_diff_element(element) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/diffsync/helpers.py", line 379, in sync_diff_element changed, modified_model = self.sync_model(src_model=src_model, dst_model=dst_model, ids=ids, attrs=attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/diffsync/helpers.py", line 436, in sync_model dst_model = dst_model.delete() ^^^^^^^^^^^^^^^^^^ File "/opt/nautobot/lib/python3.11/site-packages/nautobot_ssot/integrations/aci/diffsync/models/nautobot.py", line 139, in delete _devicetype.delete() File "/opt/nautobot/lib/python3.11/site-packages/nautobot/dcim/models/devices.py", line 375, in delete super().delete(*args, **kwargs) File "/opt/nautobot/lib/python3.11/site-packages/django/db/models/base.py", line 1131, in delete collector.collect([self], keep_parents=keep_parents) File "/opt/nautobot/lib/python3.11/site-packages/django/db/models/deletion.py", line 355, in collect raise ProtectedError( django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'DeviceType' because they are referenced through protected foreign keys: 'Device.device_type'.", {<Device: A>, <Device: B>, <Device: C>, <Device: D>})

Observed Behavior

When more than 1 fabric are synced using the app, and one fabric does not contain the same device types that the other fabric(s) do, the plugin attempts to remove the device type definitions because they are not present in syncing fabric. This causes an error because the device type definitons are tied to devices created from the other fabric sync jobs.

Steps to Reproduce

  1. Configure SSoT to talk to 2 unique fabrics
  2. Ensure each external integration uses a unique "tenant_prefix" extra config setting so the fabric tenant names do not collide.
  3. Have a mismatch between the 2 fabrics with the device models deployed
  4. Run a sync job against the fabric that has a device model that is not included in the secondary fabric
  5. Run a sync job against the secondary fabric.
  6. Observe the error of the job trying to remove a devicetype that was populated from the other fabric's sync job.
@gsnider2195 gsnider2195 added the type: bug Issues/PRs addressing a bug. label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues/PRs addressing a bug.
Projects
None yet
Development

No branches or pull requests

2 participants