Open tbotnz opened 22 hours ago
Same problem with v4.1.6
Can this be addressed with documentation, e.g. a note that if you add an API endpoint in your plugin you need to flush your redis cache (with accompanying instructions)?
In my mind what should happen is the cached swagger should clear on container/app startup if its deemed out of date
here a simple management command that fixes it once called python manage.py $command_file_name
$command_file_name.py
from django.core.management.commands.makemigrations import Command as _Command
from django.core.cache import cache
class Command(_Command):
def handle(self, *args, **kwargs):
""" Temporary command to clear cache keys that are not cleared by the cache clear command. """
_KEYS_PREFIX_REQUIRING_CLEARING = [
"*api_schema_*",
]
for key_prefix in _KEYS_PREFIX_REQUIRING_CLEARING:
matched_keys_to_delete = cache.keys(key_prefix)
for matched_key in matched_keys_to_delete:
cache.delete(matched_key)
Deployment Type
Self-hosted
Triage priority
N/A
NetBox Version
v4.1.3
Python Version
3.11
Steps to Reproduce
1) add an endpoint to an API plugin 2) reload netbox
Expected Behavior
swagger should update showing the new endpoint
Observed Behavior
Problem is caused by the caching of the swagger in redis, this needs to be cleared every time in order for the swagger to update. It does appear to load after the cache expires but this takes 24 hours