Device with connected interface can not be deleted #1960

Closed
opened 2025-12-29 17:20:57 +01:00 by adam · 2 comments
Owner

Originally created by @Armadill0 on GitHub (Aug 21, 2018).

Environment

  • Python version: 2.7.9
  • NetBox version: 2.4.3

Steps to Reproduce

  1. create a device with a physical interface
  2. create interface connection to another device
  3. delete the device

This is not reproducible with all devices with interface connections we have in our database. I tried it at least 50 or 60 times with many different devices (old and newly created). It is always reproducible with the affected devices, but I could not find common similarities and strict differences between the affected and not affected devices.

I also found #2323 and it seems to be nearly the same issue but with devices instead of virtual machines.

Expected Behavior

Device should have been successfully deleted with all it's interfaces.

If all interfaces with existing connections to other interfaces are being deleted and you delete the device afterwards everything works as expected.

Observed Behavior

Server error:
netbox-device-with-connection-not-deletable

Stack trace:

2018-08-21 14:37:21,894 ERROR Internal Server Error: /dcim/devices/1581/delete/
Traceback (most recent call last):
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/contrib/auth/mixins.py", line 92, in dispatch
    return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/webapps/netbox/netbox/utilities/views.py", line 280, in post
    obj.delete()
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/base.py", line 974, in delete
    return collector.delete()
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/deletion.py", line 308, in delete
    sender=model, instance=obj, using=self.using
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/utils/functional.py", line 15, in _curried
    return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs))
  File "/opt/webapps/netbox/netbox/extras/middleware.py", line 37, in _record_object_deleted
    instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE)
  File "/opt/webapps/netbox/netbox/dcim/models.py", line 2088, in log_change
    related_object=interface.parent,
  File "/opt/webapps/netbox/netbox/dcim/models.py", line 1960, in parent
    return self.device or self.virtual_machine
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py", line 184, in __get__
    rel_obj = self.get_object(instance)
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py", line 159, in get_object
    return qs.get(self.field.get_reverse_related_filter(instance))
  File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
DoesNotExist: Device matching query does not exist.
Originally created by @Armadill0 on GitHub (Aug 21, 2018). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 2.7.9 * NetBox version: 2.4.3 <!-- Describe in detail the steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). --> ### Steps to Reproduce 1. create a device with a physical interface 2. create interface connection to another device 3. delete the device This is not reproducible with all devices with interface connections we have in our database. I tried it at least 50 or 60 times with many different devices (old and newly created). It is always reproducible with the affected devices, but I could not find common similarities and strict differences between the affected and not affected devices. I also found #2323 and it seems to be nearly the same issue but with devices instead of virtual machines. <!-- What did you expect to happen? --> ### Expected Behavior Device should have been successfully deleted with all it's interfaces. If all interfaces with existing connections to other interfaces are being deleted and you delete the device afterwards everything works as expected. <!-- What happened instead? --> ### Observed Behavior Server error: ![netbox-device-with-connection-not-deletable](https://user-images.githubusercontent.com/6536990/44394943-c19f6300-a538-11e8-85ef-2f53f19162fa.png) Stack trace: ``` 2018-08-21 14:37:21,894 ERROR Internal Server Error: /dcim/devices/1581/delete/ Traceback (most recent call last): File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/contrib/auth/mixins.py", line 92, in dispatch return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch return handler(request, *args, **kwargs) File "/opt/webapps/netbox/netbox/utilities/views.py", line 280, in post obj.delete() File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/base.py", line 974, in delete return collector.delete() File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/deletion.py", line 308, in delete sender=model, instance=obj, using=self.using File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send for receiver in self._live_receivers(sender) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/utils/functional.py", line 15, in _curried return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs)) File "/opt/webapps/netbox/netbox/extras/middleware.py", line 37, in _record_object_deleted instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE) File "/opt/webapps/netbox/netbox/dcim/models.py", line 2088, in log_change related_object=interface.parent, File "/opt/webapps/netbox/netbox/dcim/models.py", line 1960, in parent return self.device or self.virtual_machine File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py", line 184, in __get__ rel_obj = self.get_object(instance) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py", line 159, in get_object return qs.get(self.field.get_reverse_related_filter(instance)) File "/opt/virtualenvs/webapps_netbox/local/lib/python2.7/site-packages/django/db/models/query.py", line 380, in get self.model._meta.object_name DoesNotExist: Device matching query does not exist. ```
adam closed this issue 2025-12-29 17:20:57 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 21, 2018):

It is always reproducible with the affected devices

I have not been able to reproduce this issue since #2323 was addresses in v2.4.2. Please provide the exact steps needed to recreate one of these devices.

@jeremystretch commented on GitHub (Aug 21, 2018): > It is always reproducible with the affected devices I have not been able to reproduce this issue since #2323 was addresses in v2.4.2. Please provide the exact steps needed to recreate one of these devices.
Author
Owner

@Armadill0 commented on GitHub (Aug 28, 2018):

I had no more time for further investigation on this issue. Fortunately this seems to be solved with 2.4.4. Maybe #2353 fixed this.

@Armadill0 commented on GitHub (Aug 28, 2018): I had no more time for further investigation on this issue. Fortunately this seems to be solved with 2.4.4. Maybe #2353 fixed this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1960