Skip to content

Commit

Permalink
Adding support for /internal/clear_cache, this triggers
Browse files Browse the repository at this point in the history
a cache clear for deleting all cached keys.
  • Loading branch information
abellotti committed Nov 7, 2022
1 parent cf0f41c commit f52f88b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions cloudigrade/internal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class PermissiveAPIRootView(routers.APIRootView):
# URL patterns for potentially-destructive custom commands.
urlpatterns += [
path("cache/<str:key>/", views.cache_keys, name="internal-cache"),
path("clear_cache/", views.clear_cache, name="internal-clear-cache"),
path(
"delete_cloud_accounts_not_in_sources/",
views.delete_cloud_accounts_not_in_sources,
Expand Down
11 changes: 11 additions & 0 deletions cloudigrade/internal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,17 @@ def cache_keys(request, key):
return Response(data=None)


@api_view(["POST"])
@authentication_classes([IdentityHeaderAuthenticationInternal])
@permission_classes([permissions.AllowAny])
@schema(None)
def clear_cache(request):
"""Post clear all cache keys."""
logger.info(_("Clearing all cache keys"))
cache.clear()
return Response(data=None)


@api_view(["GET"])
@authentication_classes([IdentityHeaderAuthenticationInternal])
@permission_classes([permissions.AllowAny])
Expand Down

0 comments on commit f52f88b

Please sign in to comment.