Removing Module Bays with Children Power Ports breaks Power Ports count #8758

Closed
opened 2025-12-29 20:40:51 +01:00 by adam · 1 comment
Owner

Originally created by @Breadberry07 on GitHub (Oct 19, 2023).

Originally assigned to: @arthanson on GitHub.

NetBox version

v3.6.4

Python version

3.8

Steps to Reproduce

  1. Create module types for device (for example PWR-MX960-4100-AC with 2 power ports):
    image
  2. In Devices add to chassis device (for example mx960) PEM module:
    image
  3. Check count Power Ports:
    image
  4. Delete module from device:
    image

Expected Behavior

For the Power Ports count to be correct

Observed Behavior

The port counter has not decreased

Originally created by @Breadberry07 on GitHub (Oct 19, 2023). Originally assigned to: @arthanson on GitHub. ### NetBox version v3.6.4 ### Python version 3.8 ### Steps to Reproduce 1. Create module types for device (for example PWR-MX960-4100-AC with 2 power ports): ![image](https://github.com/netbox-community/netbox/assets/122742913/a3f14cf5-ffd4-4c1f-987a-77893388b62a) 2. In Devices add to chassis device (for example mx960) PEM module: ![image](https://github.com/netbox-community/netbox/assets/122742913/83ff33db-399c-4180-a834-b38d29ca56a4) 3. Check count Power Ports: ![image](https://github.com/netbox-community/netbox/assets/122742913/6c005529-2066-41e0-b529-7e47489494e2) 4. Delete module from device: ![image](https://github.com/netbox-community/netbox/assets/122742913/58478124-b73a-4a7a-b9a2-040b2c36ab4d) ### Expected Behavior For the Power Ports count to be correct ### Observed Behavior The port counter has not decreased
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 20:40:51 +01:00
adam closed this issue 2025-12-29 20:40:51 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Oct 20, 2023):

Similarly removing a rearport that is associated with a frontport will not decrement the rearport count. Deleting an inventory item that has children also does not account for the children in the count, so deleting an inventoryitem named parent_inventoryitem that has one child inventory item child_inventoryitem will decrese the counter by 1 instead of 2.

I assume the counting logic is broken for any and all CASCADE deleted objects.

@kkthxbye-code commented on GitHub (Oct 20, 2023): Similarly removing a rearport that is associated with a frontport will not decrement the rearport count. Deleting an inventory item that has children also does not account for the children in the count, so deleting an inventoryitem named `parent_inventoryitem` that has one child inventory item `child_inventoryitem` will decrese the counter by 1 instead of 2. I assume the counting logic is broken for any and all CASCADE deleted objects.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8758