-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallel Region Create API calls can produce top-level regions with the same tree_id
#12336
Comments
This looks like it is due to django-mptt/django-mptt#677 see: django-mptt/django-mptt#555 but the PR is stagnant so marking this as blocked for either #6587 or #11421 |
Hi @arthanson , I have tested this against your branch but unfortunately I still get the same behaviour. The netbox stack was totally clean to start with, and running against a docker image built from your branch:
When running the Terraform code I pasted originally, I see the following region structure gets produced: |
Thanks @DevOpsFu I guess I will have to change to use locks, will get a new version out shortly. |
@DevOpsFu could you please try one more time, I've updated the PR to use postgres locks which I hope will fix it. |
@arthanson Looks good! I did a few create/destroy cycles with the above TF code and the region tree looked correct every time. Thanks for looking at this! |
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:
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 thedcim_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: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.The text was updated successfully, but these errors were encountered: