Region Nesting Display Failure #3548

Closed
opened 2025-12-29 18:29:48 +01:00 by adam · 11 comments
Owner

Originally created by @PhillSimonds on GitHub (Apr 7, 2020).

Originally assigned to: @DanSheps on GitHub.

Environment

  • Python version: 3.7.7
  • NetBox version: 2.7.7, 2.7.11 (both)

Steps to Reproduce

  1. Create Canada as a region
  2. Create United States as a region
  3. Create Colorado and California as regions, nested under the United States
  4. Create Ontario and British Columbia as regions nested under Canada
  5. Create New Mexico as a region with NO nesting
  6. Edit New Mexico to be nested under Canada
  7. Edit New Mexico to be nested under United states

Expected Behavior

I expected to see New Mexico nested under United States from the Organizations -> Regions view.

Observed Behavior

New Mexico doesn't show as nested under United States from the Organizations -> Regions view. All other attempts to nest regions under United States fail - weather from initial Region object creation, or attempts to move an existing region object into United States

Note - you can see a video of this behavior here: https://youtu.be/nXfYlhJeUyY

Originally created by @PhillSimonds on GitHub (Apr 7, 2020). Originally assigned to: @DanSheps on GitHub. ### Environment * Python version: 3.7.7 * NetBox version: 2.7.7, 2.7.11 (both) ### Steps to Reproduce 1. Create `Canada` as a region 2. Create `United States` as a region 3. Create `Colorado` and `California` as regions, nested under the `United States` 4. Create `Ontario` and `British Columbia` as regions nested under `Canada` 5. Create `New Mexico` as a region with NO nesting 6. Edit `New Mexico` to be nested under Canada 7. Edit `New Mexico` to be nested under United states ### Expected Behavior I expected to see `New Mexico` nested under `United States` from the `Organizations -> Regions` view. ### Observed Behavior `New Mexico` doesn't show as nested under `United States` from the `Organizations -> Regions` view. All other attempts to nest regions under `United States` fail - weather from initial Region object creation, or attempts to move an existing region object into `United States` Note - you can see a video of this behavior here: https://youtu.be/nXfYlhJeUyY
adam added the type: bugstatus: accepted labels 2025-12-29 18:29:48 +01:00
adam closed this issue 2025-12-29 18:29:48 +01:00
Author
Owner

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

I think this might actually be an upstream issue. I will have to dig into it more, but I can replicate this as well as another bug.

@DanSheps commented on GitHub (Apr 7, 2020): I think this might actually be an upstream issue. I will have to dig into it more, but I can replicate this as well as another bug.
Author
Owner

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

Some more testing, on develop I am unable to reproduce this. Going to keep this open until we release 2.7.12 and see if it is resolved. Not sure of the actual cause of this.

To be clear, do not upgrade to develop, please wait for it to be released.

@DanSheps commented on GitHub (Apr 7, 2020): Some more testing, on develop I am unable to reproduce this. Going to keep this open until we release 2.7.12 and see if it is resolved. Not sure of the actual cause of this. To be clear, do not upgrade to develop, please wait for it to be released.
Author
Owner

@PhillSimonds commented on GitHub (Apr 7, 2020):

Confirmed. Thanks Dan!

@PhillSimonds commented on GitHub (Apr 7, 2020): Confirmed. Thanks Dan!
Author
Owner

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

@PhillSimonds Could you try with Caching disabled? It looks like it could potentially be a caching issue

@DanSheps commented on GitHub (Apr 7, 2020): @PhillSimonds Could you try with Caching disabled? It looks like it could potentially be a caching issue
Author
Owner

@PhillSimonds commented on GitHub (Apr 7, 2020):

@DanSheps can you confirm how I would go about doing so? I'm seeing a way to invalidate the cache from docs but don't see a way to disable completely... maybe just missing it?

@PhillSimonds commented on GitHub (Apr 7, 2020): @DanSheps can you confirm how I would go about doing so? I'm seeing a way to invalidate the cache from docs but don't see a way to disable completely... maybe just missing it?
Author
Owner

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

In your configuration.py, set CACHE_TIMEOUT to 0 (defaults to 900 normally) and restart

@DanSheps commented on GitHub (Apr 7, 2020): In your configuration.py, set `CACHE_TIMEOUT` to 0 (defaults to 900 normally) and restart
Author
Owner

@PhillSimonds commented on GitHub (Apr 7, 2020):

Confirmed. That looks like it worked.

  • Site didn't display correctly without user interaction after disabling cache.
  • On move out of United States region (to a different region), then back into United States region, it displayed it's nesting correctly.
  • Subsequent moves/additions to United States region show proper nesting with cache disabled.
@PhillSimonds commented on GitHub (Apr 7, 2020): Confirmed. That looks like it worked. - Site didn't display correctly without user interaction after disabling cache. - On move out of `United States` region (to a different region), then back into `United States` region, it displayed it's nesting correctly. - Subsequent moves/additions to `United States` region show proper nesting with cache disabled.
Author
Owner

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

Awesome, thanks

@DanSheps commented on GitHub (Apr 7, 2020): Awesome, thanks
Author
Owner

@stale[bot] commented on GitHub (Apr 22, 2020):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@stale[bot] commented on GitHub (Apr 22, 2020): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@lampwins commented on GitHub (Apr 22, 2020):

Okay, so the root cause of this is caching of get ops on the Region model internal to tree rebalancing. So the parent field is being properly set on an update but the result of the rebalance is incorrect due to erroneous get results from the cache.

The fix for this is easy, we just need to except get ops from the region model, and all MPTT models for that matter.

'dcim.region': {'ops': {'list'}},
'dcim.*': {'ops': 'all'},
@lampwins commented on GitHub (Apr 22, 2020): Okay, so the root cause of this is caching of `get` ops on the Region model internal to tree rebalancing. So the `parent` field is being properly set on an update but the result of the rebalance is incorrect due to erroneous `get` results from the cache. The fix for this is easy, we just need to except `get` ops from the region model, and all MPTT models for that matter. ``` 'dcim.region': {'ops': {'list'}}, 'dcim.*': {'ops': 'all'}, ```
Author
Owner

@lampwins commented on GitHub (Apr 22, 2020):

After further digging, we decided to simply exempt MPTT models from all caching due to their reliance on raw sql for tree rebalancing. This pertains to regions, rack groups, and tenant groups currently.

@lampwins commented on GitHub (Apr 22, 2020): After further digging, we decided to simply exempt MPTT models from all caching due to their reliance on raw sql for tree rebalancing. This pertains to regions, rack groups, and tenant groups currently.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3548