-
Notifications
You must be signed in to change notification settings - Fork 89
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
Update for NetBox 4.0.7; Add more logging, error checking; Fix #134, … #145
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried running your PR and I encountered a few issues. I outlined what I did to fix those here.
It also seems that some of the changes for retries upon connection errors is not working 100% as I have had instances where the Netbox server gets temporarily overloaded and returns a 502 connection error and the importer is not catching this and it causes it to crash. Previous versions would simply continue to the next request. Traceback (most recent call last):
File "/app/nb-dt-import.py", line 68, in <module>
main()
File "/app/nb-dt-import.py", line 30, in main
netbox.create_device_types(device_types)
File "/app/netbox_api.py", line 138, in create_device_types
self.device_types.create_interfaces(device_type["interfaces"], dt.id)
File "/app/netbox_api.py", line 281, in create_interfaces
existing_interfaces = {str(item): item for item in self.netbox.dcim.interface_templates.filter(
File "/app/netbox_api.py", line 281, in <dictcomp>
existing_interfaces = {str(item): item for item in self.netbox.dcim.interface_templates.filter(
File "/usr/local/lib/python3.9/site-packages/pynetbox/core/response.py", line 128, in __next__
next(self.response), self.endpoint.api, self.endpoint
File "/usr/local/lib/python3.9/site-packages/pynetbox/core/query.py", line 292, in get
req = self._make_call(add_params=add_params)
File "/usr/local/lib/python3.9/site-packages/pynetbox/core/query.py", line 259, in _make_call
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 502 Bad Gateway but more specific details were not returned in json. Check the NetBox Logs or investigate this exception's error attribute. |
The default value needs to be a string to prevent conversion errors, as we assume the user provided variable is a string (due to the way DotEnv handle variables)
I'm having trouble getting the 502 issue to reproduce on a fresh test environment, so that one may have to wait a week or so for me to get back to my dev environment. To assist me in reproducing, could you provide the NetBox logs from the time around the import? Additionally, can you confirm NetBox is still usable from the web both before and after performing an import? This is to verify that is a connectivity issue to the importer and not an issue in NetBox itself going offline. As an alternative possibility, it looks like this may possibly be solved by amending netbox_api.py on line 164 to read as Let me know if you try the latter, and if it works I'll update the pull request with the new code. |
Verified working with: