Skip to content

Parallel Region Create API calls can produce top-level regions with the same tree_id #12336

@DevOpsFu

Description

@DevOpsFu

NetBox version

v3.4.8

Python version

3.8

Steps to Reproduce

Ref: e-breuninger/terraform-provider-netbox#385

Using a tool which will produce parallel API calls to NetBox (e.g. Terraform), create two or more top-level Region objects with children, via the /dcim/regions endpoint.

In Terraform, this might look like this:

resource "netbox_region" "uk" {
  name = "United Kingdom"
}

resource "netbox_region" "ireland" {
  name = "Ireland"
}

resource "netbox_region" "london" {
  name             = "London"
  parent_region_id = netbox_region.uk.id
}

resource "netbox_region" "gatwick" {
  name             = "Gatwick"
  parent_region_id = netbox_region.uk.id
}



resource "netbox_region" "northeurope" {
  name             = "Azure North Europe"
  parent_region_id = netbox_region.ireland.id
}

resource "netbox_region" "uksouth" {
  name             = "Azure UK South"
  parent_region_id = netbox_region.london.id
}

Expected Behavior

The Regions are created with the correct tree structure in the NetBox UI

Observed Behavior

The top-level regions can sometimes be created with the same tree_id in the dcim_region table. This causes some weird UI issues whereby all the child regions will appear under one of the top-level regions, despite it not being their parent:

image

image

If you follow the child region links, the Parent IDs are set correctly.

To work around this, we can ensure that the top-level regions are created in serial so that they never receive the same tree_id value.

Metadata

Metadata

Assignees

Labels

severity: mediumResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions