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

Unable to delete device after upgrade to 2.4.3 #2353

Closed
jnfohr opened this issue Aug 13, 2018 · 3 comments
Closed

Unable to delete device after upgrade to 2.4.3 #2353

jnfohr opened this issue Aug 13, 2018 · 3 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jnfohr
Copy link

jnfohr commented Aug 13, 2018

Environment

  • Python version: 3.5.2
  • NetBox version: 2.4.3

Steps to Reproduce

  • Upgrade from 2.3.6 to 2.4.3
  • Clic "Delete this device" from web UI for an already existing device and hit "Confirm"

Expected Behavior

  • Deletion of the device

Observed Behavior

Error message:

<class 'dcim.models.DoesNotExist'>

Device matching query does not exist.

And device is not deleted. This is not happening for all existing devices.

Stacktrace

Internal Server Error: /dcim/devices/187/delete/

DoesNotExist at /dcim/devices/187/delete/
Device matching query does not exist.

Request Method: POST
Request URL: http://netbox/dcim/devices/187/delete/
Django Version: 2.0.8
Python Executable: /usr/bin/python3
Python Version: 3.5.2
Python Path: ['/opt/netbox/netbox', '/opt/netbox/netbox', '/usr/local/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Mon, 13 Aug 2018 13:35:04 +0000
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'mptt',
 'rest_framework',
 'taggit',
 'taggit_serializer',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'drf_yasg']
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware')


Traceback:

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in __get__
  158.             rel_obj = self.field.get_cached_value(instance)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/mixins.py" in get_cached_value
  13.             return instance._state.fields_cache[cache_name]

During handling of the above exception ('device'), another exception occurred:

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/mixins.py" in dispatch
  85.         return super().dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in post
  280.                 obj.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in delete
  891.         return collector.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/deletion.py" in delete
  307.                             sender=model, instance=obj, using=self.using

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in send
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in <listcomp>
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py" in _curried
  11.         return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs))

File "/opt/netbox/netbox/extras/middleware.py" in _record_object_deleted
  37.         instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE)

File "/opt/netbox/netbox/dcim/models.py" in log_change
  2088.                 related_object=interface.parent,

File "/opt/netbox/netbox/dcim/models.py" in parent
  1960.         return self.device or self.virtual_machine

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in __get__
  164.                 rel_obj = self.get_object(instance)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in get_object
  139.         return qs.get(self.field.get_reverse_related_filter(instance))

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in get
  403.                 self.model._meta.object_name

Exception Type: DoesNotExist at /dcim/devices/187/delete/
Exception Value: Device matching query does not exist.
@jeremystretch
Copy link
Member

This is not happening for all existing devices.

Could you please list the steps necessary to recreate the error, beginning with the creation of a new device? This is necessary to develop a fix.

Looks related to #2323.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Aug 13, 2018
@jnfohr
Copy link
Author

jnfohr commented Aug 14, 2018

When creating a new device i'm not able to recreate the issue.

I'v been doing some tests and found out that the error disappears and i'm able to delete the device once i disconnect or delete the network interfaces (disconnect is enough). But changing the network interface parameters (name, status, type) has no effect.

What's surprising is that it just occurs with a few devices and is hardly reproductible. Deleting the switch facing the device while the interfaces are connected is possible and does not return any error.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation and removed status: revisions needed This issue requires additional information to be actionable labels Aug 22, 2018
@jeremystretch
Copy link
Member

I can't recreate this but we should be able to avoid it by catching the exception in InterfaceConnection.log_change().

@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants