Child devices disappear from the list of Non-Racked Devices if new child device is created #3648

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

Originally created by @jones-g on GitHub (May 7, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.0

Steps to Reproduce

  1. Create a device type that is a parent device and create 2 or more device bays on parent device
  2. Create a device type that is a child device
  3. Create device from parent device type and place in rack
  4. Create device from child device type and place in rack
  5. Insert child device in parent device
  6. Create another device from child device type and place in same rack

Expected Behavior

Expected to see both child devices in "Non-Racked Devices" on rack at step 6. The first with parent set and the second without parent set.

Observed Behavior

At step 4 and 5 the first child device is shown in the "Non-Racked Devices" as expected. At step 4 with no parent and at step 5 with the parent device set. Upon creating the second child device in step 6 - if the first child device is already placed inside a device bay it disappears from the list of "Non-Racked Devices" and only the second child device is show.

Confirmed on netboxdemo.com running version 2.8.1 as well.

Originally created by @jones-g on GitHub (May 7, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. 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, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.8 * NetBox version: 2.8.0 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Create a device type that is a parent device and create 2 or more device bays on parent device 2. Create a device type that is a child device 3. Create device from parent device type and place in rack 4. Create device from child device type and place in rack 5. Insert child device in parent device 6. Create another device from child device type and place in same rack <!-- What did you expect to happen? --> ### Expected Behavior Expected to see both child devices in "Non-Racked Devices" on rack at step 6. The first with parent set and the second without parent set. <!-- What happened instead? --> ### Observed Behavior At step 4 and 5 the first child device is shown in the "Non-Racked Devices" as expected. At step 4 with no parent and at step 5 with the parent device set. Upon creating the second child device in step 6 - if the first child device is already placed inside a device bay it disappears from the list of "Non-Racked Devices" and only the second child device is show. Confirmed on netboxdemo.com running version 2.8.1 as well.
adam added the type: bugstatus: accepted labels 2025-12-29 18:30:21 +01:00
adam closed this issue 2025-12-29 18:30:21 +01:00
Author
Owner

@DanSheps commented on GitHub (May 7, 2020):

Expected to see both child devices in "Non-Racked Devices" on rack at step 6. The first with parent set and the second without parent set.

This is not correct. After step 5, the device is "racked" in the bay of the first device, hence why it does not show in the "Non-Racked" devices.

Just to confirm.

  • You create a parent
  • You create a child
  • You rack the parent in the rack (lets say U34)
  • You "rack" the child as an unracked device
  • You place the child in the parent

If so, this looks like a cache invalidation problem as removing the second child does not replace the blade back in the unrack section. Additionally, editing the blade will also remove it.

@DanSheps commented on GitHub (May 7, 2020): > Expected to see both child devices in "Non-Racked Devices" on rack at step 6. The first with parent set and the second without parent set. This is not correct. After step 5, the device is "racked" in the bay of the first device, hence why it does not show in the "Non-Racked" devices. Just to confirm. * You create a parent * You create a child * You rack the parent in the rack (lets say U34) * You "rack" the child as an unracked device * You place the child in the parent If so, this looks like a cache invalidation problem as removing the second child does not replace the blade back in the unrack section. Additionally, editing the blade will also remove it.
Author
Owner

@jones-g commented on GitHub (May 11, 2020):

Cache invalidation problem sounds very reasonable.

Indeed the process is correct. I have captured some screenshots to demonstrate. If I in step 4 create two child devices (Blade1 and Blade2) and rack them as unracked devices they show up as expected:
image

If I then place Blade1 in device bay 1 of Chassis1 I get this:
image

If I then place Blade2 in device bay 2 of Chassis 1 I get this:
image

But as soon as I add a new unracked child device, Blade3, to the rack - both Blade 1 and 2 disappear:
image

Which behaviour is the correct one I am not certain of. From your comment the fact that Blade 1 and 2 remain in unracked devices seems to be the incorrect behaviour.

Let me know if you need more information.

@jones-g commented on GitHub (May 11, 2020): Cache invalidation problem sounds very reasonable. Indeed the process is correct. I have captured some screenshots to demonstrate. If I in step 4 create two child devices (Blade1 and Blade2) and rack them as unracked devices they show up as expected: ![image](https://user-images.githubusercontent.com/5399484/81532322-79efe900-9364-11ea-87fb-81857fc8d762.png) If I then place Blade1 in device bay 1 of Chassis1 I get this: ![image](https://user-images.githubusercontent.com/5399484/81532381-90964000-9364-11ea-838d-a53348d49e2a.png) If I then place Blade2 in device bay 2 of Chassis 1 I get this: ![image](https://user-images.githubusercontent.com/5399484/81532414-9f7cf280-9364-11ea-9add-8b1a57654988.png) But as soon as I add a new unracked child device, Blade3, to the rack - both Blade 1 and 2 disappear: ![image](https://user-images.githubusercontent.com/5399484/81532462-b4f21c80-9364-11ea-8e02-7766cc8570c5.png) Which behaviour is the correct one I am not certain of. From your comment the fact that Blade 1 and 2 remain in unracked devices seems to be the incorrect behaviour. Let me know if you need more information.
Author
Owner

@lampwins commented on GitHub (May 15, 2020):

@jeremystretch I am a little confused about the intended behavior here. As I recall once a child device is installed in a racked parent, that child is also considered racked. However, the non-racked devices table includes a parent column. I assume this was intended to cover a case in which a parent is not racked and thus the children should show up in the table too? If that is the case, I think we have a separate bug, because the existing query would not allow the inclusion of the child devices in such a case because of parent_bay__isnull=True:

nonracked_devices = Device.objects.filter(
    rack=rack,
    position__isnull=True,
    parent_bay__isnull=True
).prefetch_related('device_type__manufacturer')
@lampwins commented on GitHub (May 15, 2020): @jeremystretch I am a little confused about the intended behavior here. As I recall once a child device is installed in a racked parent, that child is also considered racked. However, the non-racked devices table includes a parent column. I assume this was intended to cover a case in which a parent is not racked and thus the children should show up in the table too? If that is the case, I think we have a separate bug, because the existing query would not allow the inclusion of the child devices in such a case because of `parent_bay__isnull=True`: ``` nonracked_devices = Device.objects.filter( rack=rack, position__isnull=True, parent_bay__isnull=True ).prefetch_related('device_type__manufacturer') ```
Author
Owner

@lampwins commented on GitHub (May 19, 2020):

As for the actual caching issue here, it appears to be related to the use of a related name (parent_bay) with an isnull option. I have raised #353 upstream.

@lampwins commented on GitHub (May 19, 2020): As for the actual caching issue here, it appears to be related to the use of a related name (`parent_bay`) with an `isnull` option. I have raised [#353](https://github.com/Suor/django-cacheops/issues/353) upstream.
Author
Owner

@DanSheps commented on GitHub (May 20, 2020):

Blocked: Suor/django-cacheops#353

@DanSheps commented on GitHub (May 20, 2020): Blocked: Suor/django-cacheops#353
Author
Owner

@DanSheps commented on GitHub (May 20, 2020):

As far as what @lampwins mentions about the Parent column, I think once a child is put in a bay, I think we should consider it "racked", at least to the parent, so we might want to ditch the Parent column. If no one has objections, I am going to open a issue for that one

@DanSheps commented on GitHub (May 20, 2020): As far as what @lampwins mentions about the Parent column, I think once a child is put in a bay, I think we should consider it "racked", at least to the parent, so we might want to ditch the Parent column. If no one has objections, I am going to open a issue for that one
Author
Owner

@DanSheps commented on GitHub (Jun 22, 2020):

Looks like this got fixed upstream, we will just need to wait for the next release of cacheops

@DanSheps commented on GitHub (Jun 22, 2020): Looks like this got fixed upstream, we will just need to wait for the next release of cacheops
Author
Owner

@jeremystretch commented on GitHub (Jul 16, 2020):

I ended up just cleaning up the table to include both 0U and child devices. Did away with the parent_bay__isnull filter on the queryset so that both types of device are included.

@jeremystretch commented on GitHub (Jul 16, 2020): I ended up just cleaning up the table to include both 0U and child devices. Did away with the `parent_bay__isnull` filter on the queryset so that both types of device are included.
Author
Owner

@willbuckner commented on GitHub (Oct 1, 2020):

On v2.8.9, even after wiping Redis to clear the cache, I see all of my child devices (whose parents are racked) showing up in Unracked Devices. Looking at the commit for this issue, 9d243103f4, it seems this is now intended behavior, but it's very not ideal for my use case. A 0U PDU is an unracked device, but a blade server is not. It's racked, inside the parent device. Now I can't distinguish devices which are not yet installed or are missing necessary rack elevation data, from devices which are correctly installed inside a racked parent device.

@willbuckner commented on GitHub (Oct 1, 2020): On v2.8.9, even after wiping Redis to clear the cache, I see all of my child devices (whose parents are racked) showing up in Unracked Devices. Looking at the commit for this issue, 9d243103f494923ed97538ad866526688d4809e9, it seems this is now intended behavior, but it's very not ideal for my use case. A 0U PDU is an unracked device, but a blade server is not. It's racked, inside the parent device. Now I can't distinguish devices which are not yet installed or are missing necessary rack elevation data, from devices which are correctly installed inside a racked parent device.
Author
Owner

@DanSheps commented on GitHub (Oct 2, 2020):

If you think the other way is better, it may be best to open a FR for it instead of posting in here.

Make sure you provide ample justification however.

@DanSheps commented on GitHub (Oct 2, 2020): If you think the other way is better, it may be best to open a FR for it instead of posting in here. Make sure you provide ample justification however.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3648