Skip to content

Handle netbox api cache more gracefully #1111

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

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

sc68cal
Copy link
Contributor

@sc68cal sc68cal commented Oct 30, 2023

This fixes #1106

There are instances where we fail to read the cached
netbox_api_dump.json file, and the code was setting openapi to an empty
dictionary, and netbox_api_version to 0.

This is not correct, because we can still fetch the netbox_api_version
by querying the live server. In addition, in cases where the cached API was
failing to read, it would end up triggering the if/else statement to try
and access the older API doc endpoint, even if the server was not <
3.5.0

Overall the code was very convoluted and could break if the cached file
was not readable or writable. This patch cleans the logic up and makes
it more clear what is going on.
@sc68cal sc68cal requested a review from rodvand October 31, 2023 14:51
@rodvand rodvand merged commit 159f309 into netbox-community:devel Nov 2, 2023
@sc68cal sc68cal deleted the handle_cache_failure branch November 2, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: NetBox API caching logic has issues
2 participants