-
Notifications
You must be signed in to change notification settings - Fork 218
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
[Bug]: nb_inventory is taking several minutes to run due to the "limit&offset" behaviour. Can we turn that off? #1370
Comments
Can you also do a test where you do the API call without the limit, then with the limit to just make sure it's not the case where the first API call warmed up a cache? |
Curl doesn't cache anything, but incase there could be caching on netbox itself....
|
But I'm not so concerned with the performance of the raw curl, but more with the performance of the curl commands vs the nb_inventory plugin. 2 seconds -> 13 seconds is far less concerning than 2/13 seconds to almost 7 minutes |
I understand. However looking at your logs it appears that you have over 31k virtual machines. Thank you for checking that we are getting the same amount of machines with the limit vs non limit query because that was going to be my next suspicion as well. We need to investigate why the inventory plugin is pulling in chunks, perhaps at one point it was needed in order to not hammer NetBox but it appears that forcing NetBox to do pagination is making performance worse now. |
So doing more investigation on this it seems that there are some NetBox configuration settings that come into play here. The big one is that, by default, MAX_PAGE_SIZE is set to 1000 which is what seems to be the underlying reason for the limit&offset. That being the case I'm not sure how we can get around the limit&offset restriction other than to use the GraphQL API instead of the regular API as it does not have that page limit restriction. That introduces a whole other complexity as there seems to be current limitations on filtering when using the the GraphQL API (netbox-community/netbox#17688). We are currently investigating how we could write a custom inventory plugin using the GraphQL API as we don't have a broad range of filter or field retrieval requirements. |
Ansible NetBox Collection version
v3.20.0
Ansible version
NetBox version
NetBox Community v4.1.11
Python version
3.11
Steps to Reproduce
Content of inventory config file:
Expected Behavior
The plugin should not be taking several minutes to run. Need an option to turn off the "limit" behavior.
Using just a single limit, takes 14 seconds
Using no limit, takes 2 seconds
Observed Behavior
Output from the above inventory command:
Inventory plugin takes almost 7 minutes
Beginning of the output file:
The text was updated successfully, but these errors were encountered: