Cannot delete devices #5038

Closed
opened 2025-12-29 19:23:25 +01:00 by adam · 11 comments
Owner

Originally created by @CheBushe on GitHub (Jul 1, 2021).

NetBox version

v2.11.7

Python version

3.6

Steps to Reproduce

  1. Trying to delete device "dev1" by pressing delete button
  2. Deletion successful
  3. Search for device "dev1" and it's exist.
  4. Trying to delete device "dev2" by pressing delete button
  5. Deletion successful
  6. Search for device "dev2" and it's doesn't exist.

Expected Behavior

The device should have been removed.

Observed Behavior

No TypeError exception was rised in normal log level.

When DEBUG log level a SQLPanel exception occurs:

(0.001) DELETE FROM "dcim_consoleport" WHERE "dcim_consoleport"."id" IN (65); args=(65,)
(0.001) DELETE FROM "dcim_consoleserverport" WHERE "dcim_consoleserverport"."id" IN (36); args=(36,)
(0.002) DELETE FROM "dcim_interface" WHERE "dcim_interface"."id" IN (1537, 1536); args=(1537, 1536)
(0.001) DELETE FROM "dcim_device" WHERE "dcim_device"."id" IN (216); args=(216,)
Exception while resolving variable 'similar_count' in template 'debug_toolbar/panels/sql.html'.
Traceback (most recent call last):
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
TypeError: 'SQLPanel' object is not subscriptable

Originally created by @CheBushe on GitHub (Jul 1, 2021). ### NetBox version v2.11.7 ### Python version 3.6 ### Steps to Reproduce 1. Trying to delete device "dev1" by pressing delete button 2. Deletion successful 3. Search for device "dev1" and it's exist. 4. Trying to delete device "dev2" by pressing delete button 5. Deletion successful 6. Search for device "dev2" and it's doesn't exist. ### Expected Behavior The device should have been removed. ### Observed Behavior No TypeError exception was rised in normal log level. When DEBUG log level a SQLPanel exception occurs: (0.001) DELETE FROM "dcim_consoleport" WHERE "dcim_consoleport"."id" IN (65); args=(65,) (0.001) DELETE FROM "dcim_consoleserverport" WHERE "dcim_consoleserverport"."id" IN (36); args=(36,) (0.002) DELETE FROM "dcim_interface" WHERE "dcim_interface"."id" IN (1537, 1536); args=(1537, 1536) (0.001) DELETE FROM "dcim_device" WHERE "dcim_device"."id" IN (216); args=(216,) Exception while resolving variable 'similar_count' in template 'debug_toolbar/panels/sql.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib64/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] TypeError: 'SQLPanel' object is not subscriptable
adam added the status: under review label 2025-12-29 19:23:25 +01:00
adam closed this issue 2025-12-29 19:23:25 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 1, 2021):

All I can gather from the information you've provided is that there's a bug concerning the Django debug toolbar. What version of it do you have installed? (Run pip freeze | grep django-debug-toolbar from within NetBox's virtual environment to check.)

@jeremystretch commented on GitHub (Jul 1, 2021): All I can gather from the information you've provided is that there's a bug concerning the Django debug toolbar. What version of it do you have installed? (Run `pip freeze | grep django-debug-toolbar` from within NetBox's virtual environment to check.)
Author
Owner

@CheBushe commented on GitHub (Jul 1, 2021):

(venv) [netbox]nbox[/opt/netbox/netbox]$ pip freeze | grep django-debug-toolbar
django-debug-toolbar==3.2.1

@CheBushe commented on GitHub (Jul 1, 2021): (venv) [netbox]nbox[/opt/netbox/netbox]$ pip freeze | grep django-debug-toolbar django-debug-toolbar==3.2.1
Author
Owner

@jeremystretch commented on GitHub (Jul 1, 2021):

I'm not sure what to suggest here, since I'm not able to replicate the reported behavior. If it was a general issue it would have showed up in our automated tests. Have you made any modifications to the NetBox code base? See if you can get a full stack trace.

@jeremystretch commented on GitHub (Jul 1, 2021): I'm not sure what to suggest here, since I'm not able to replicate the reported behavior. If it was a general issue it would have showed up in our automated tests. Have you made any modifications to the NetBox code base? See if you can get a full stack trace.
Author
Owner

@CheBushe commented on GitHub (Jul 1, 2021):

I have prod installation upgraded to latest version.
On upgrade netbox to v2.11.7 I had problem with ntc-netbox-plugin-onboarding plugin. Then I removed unsupported plugin and run ./upgrade again. That was successful.
Sometime later I tried to delete "planed" device from rack. It's not showed error or warning message. But when I look on rack the removed device still on it.
I made test installation with full copy of prod. On it I can experimented.
On test environment some devices can be removed or some not. I can't find dependencies.

Have you made any modifications to the NetBox code base?

No I had not

See if you can get a full stack trace.

Could you point me how I can?

@CheBushe commented on GitHub (Jul 1, 2021): I have prod installation upgraded to latest version. On upgrade netbox to v2.11.7 I had problem with ntc-netbox-plugin-onboarding plugin. Then I removed unsupported plugin and run ./upgrade again. That was successful. Sometime later I tried to delete "planed" device from rack. It's not showed error or warning message. But when I look on rack the removed device still on it. I made test installation with full copy of prod. On it I can experimented. On test environment some devices can be removed or some not. I can't find dependencies. > Have you made any modifications to the NetBox code base? No I had not > See if you can get a full stack trace. Could you point me how I can?
Author
Owner

@jeremystretch commented on GitHub (Jul 1, 2021):

I'm wondering if this is just a caching issue. Try setting CACHE_TIMEOUT=0 in configuration.py and restarting the WSGI workers.

@jeremystretch commented on GitHub (Jul 1, 2021): I'm wondering if this is just a caching issue. Try setting `CACHE_TIMEOUT=0` in `configuration.py` and restarting the WSGI workers.
Author
Owner

@CheBushe commented on GitHub (Jul 1, 2021):

no changes

@CheBushe commented on GitHub (Jul 1, 2021): no changes
Author
Owner

@CheBushe commented on GitHub (Jul 1, 2021):

I changed debug level:
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/var/log/netbox/netbox.log',
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',

make:
In [13]: device = nb.dcim.devices.get(name='cs5-m9')

In [14]: device.delete()
Out[14]: True

and then copied log to:
test-nos.log

Hope this helps.

@CheBushe commented on GitHub (Jul 1, 2021): I changed debug level: 'handlers': { 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': '/var/log/netbox/netbox.log', }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'DEBUG', make: In [13]: device = nb.dcim.devices.get(name='cs5-m9') In [14]: device.delete() Out[14]: True and then copied log to: [test-nos.log](https://github.com/netbox-community/netbox/files/6749537/test-nos.log) Hope this helps.
Author
Owner

@jeremystretch commented on GitHub (Jul 6, 2021):

It's likely you have an error in your configuration file; see #1474.

@jeremystretch commented on GitHub (Jul 6, 2021): It's likely you have an error in your configuration file; see #1474.
Author
Owner

@CheBushe commented on GitHub (Jul 7, 2021):

Unfortunately not my case.
I had set fqdn in ALLOWED_HOSTS on PROD install and device deletion worked early.
Another thing I can edit device but I can't remove it.
Later I'll try a new install with restore data from postgresql.

@CheBushe commented on GitHub (Jul 7, 2021): Unfortunately not my case. I had set fqdn in ALLOWED_HOSTS on PROD install and device deletion worked early. Another thing I can edit device but I can't remove it. Later I'll try a new install with restore data from postgresql.
Author
Owner

@CheBushe commented on GitHub (Jul 14, 2021):

I found the reason for the problem.
The error appeared after installing and removing the onboarding plugin (https://github.com/networktocode/ntc-netbox-plugin-onboarding)
This plugin created additional tables in which there were links to the devices to be deleted.
To solve the problem for myself, I deleted two tables created by the plugin in postrgresql:
DROP TABLE netbox_onboarding_onboardingdevice;
DROP TABLE netbox_onboarding_onboardingtask;
After that, everything works as expected.

@CheBushe commented on GitHub (Jul 14, 2021): I found the reason for the problem. The error appeared after installing and removing the onboarding plugin (https://github.com/networktocode/ntc-netbox-plugin-onboarding) This plugin created additional tables in which there were links to the devices to be deleted. To solve the problem for myself, I deleted two tables created by the plugin in postrgresql: DROP TABLE netbox_onboarding_onboardingdevice; DROP TABLE netbox_onboarding_onboardingtask; After that, everything works as expected.
Author
Owner

@jeremystretch commented on GitHub (Jul 14, 2021):

@CheBushe thanks for following up with that. I recall seeing this exact issue come up before. We might need to add documentation for the deinstallation of plugins to address such issues.

Edit: I've opened #6753 for this.

@jeremystretch commented on GitHub (Jul 14, 2021): @CheBushe thanks for following up with that. I recall seeing this exact issue come up before. We might need to add documentation for the deinstallation of plugins to address such issues. Edit: I've opened #6753 for this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5038