unnecessary save action device instance when it is removed #11161

Closed
opened 2025-12-29 21:41:10 +01:00 by adam · 5 comments
Owner

Originally created by @Taurdil on GitHub (May 12, 2025).

Deployment Type

NetBox Cloud

NetBox Version

v4.3.0

Python Version

3.12

Steps to Reproduce

  1. Create Device
  2. Create Interface of device
  3. Create IPAddress from for interface
  4. Set "Make this the primary IP for the device/VM" for IPAddress
  5. Delete Device

Expected Behavior

Only operations to delete all related objects (Device, Interface, IPAddress)

Observed Behavior

Before deleting the Device, it is updated

Originally created by @Taurdil on GitHub (May 12, 2025). ### Deployment Type NetBox Cloud ### NetBox Version v4.3.0 ### Python Version 3.12 ### Steps to Reproduce 1. Create Device 2. Create Interface of device 3. Create IPAddress from for interface 4. Set "Make this the primary IP for the device/VM" for IPAddress 5. Delete Device ### Expected Behavior Only operations to delete all related objects (Device, Interface, IPAddress) ### Observed Behavior Before deleting the Device, it is updated
adam added the type: housekeeping label 2025-12-29 21:41:10 +01:00
adam closed this issue 2025-12-29 21:41:10 +01:00
Author
Owner

@jnovinger commented on GitHub (May 12, 2025):

I'm accepting this as it does make sense--if we can remove extraneous queries and still accomplish the same outcome, then we should do it.

The code responsible for doing this (in this case) appears to be ipam.signals.clear_primary_ip and was put in place purposefully--to handle clearing the "primary IP {family}" for any devices/VMs this IP address is attached to, particularly when the device/VM is not also being deleted.

I'm not at all certain how we would go about telling whether the linked device/VM is also being deleted and therefore does not need to be updated.

@jnovinger commented on GitHub (May 12, 2025): I'm accepting this as it does make sense--if we can remove extraneous queries and still accomplish the same outcome, then we should do it. The code responsible for doing this (in this case) appears to be `ipam.signals.clear_primary_ip` and was put in place purposefully--to handle clearing the "primary IP {family}" for any devices/VMs this IP address is attached to, particularly when the device/VM is not also being deleted. I'm not at all certain how we would go about telling whether the linked device/VM is also being deleted and therefore does not need to be updated.
Author
Owner

@jnovinger commented on GitHub (May 12, 2025):

Apologies @Taurdil , I noticed your commit in your fork after making my comment above. Is this something you like to take ownership of?

@jnovinger commented on GitHub (May 12, 2025): Apologies @Taurdil , I noticed your commit in your fork after making my comment above. Is this something you like to take ownership of?
Author
Owner

@Taurdil commented on GitHub (May 13, 2025):

@jnovinger yep

@Taurdil commented on GitHub (May 13, 2025): @jnovinger yep
Author
Owner

@jeremystretch commented on GitHub (May 13, 2025):

While I can appreciate wanting to optimize this process, it is working as intended. Any conditional logic implement with the intent of bypassing the update introduces inherent complexity, increasing both development burden and risk of breakage. The negligible gains that might be realized by this change warrant neither the effort nor the risk IMO.

Additionally, I'm going to reclassify this as a housekeeping effort rather than a bug, as the application is functioning as intended.

@jeremystretch commented on GitHub (May 13, 2025): While I can appreciate wanting to optimize this process, it is working as intended. Any conditional logic implement with the intent of bypassing the update introduces inherent complexity, increasing both development burden and risk of breakage. The negligible gains that might be realized by this change warrant neither the effort nor the risk IMO. Additionally, I'm going to reclassify this as a housekeeping effort rather than a bug, as the application is functioning as intended.
Author
Owner

@jeremystretch commented on GitHub (May 16, 2025):

After further consideration, I'm going to close this as the risk associated with interfering with the current workflow does not justify whatever modest performance gains might be recognized.

@jeremystretch commented on GitHub (May 16, 2025): After further consideration, I'm going to close this as the risk associated with interfering with the current workflow does not justify whatever modest performance gains might be recognized.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11161