Backend: Clear runner cache via API

Proposal

Expose on the GitLab API an endpoint to clear the runner cache (basically the button shown below). My use case would be to periodically clear the runner caches to prevent them to becoming too stale or too bloated. In particular my Terraform caches become so bloated that they become useless and it's better to just not have a cache since the download + upload of the cache takes longer than just starting fresh without a cache.

image

When an endpoint is exposed via the API I could build automation around it to automatically clear the cache say every month for my projects.

Related issues:

I could not find a similar issue, but hard to imagine this hasn't been asked before...

image

I found one question related to this in the GitLab Forum but it has not received any response: https://forum.gitlab.com/t/clear-runner-cache-api/62965

Proposal

The ResetProjectCacheService is currently called by ci_cd_controller.rb when clicking the "Clear runner caches" button in the UI. We can expose this service in a GraphQL mutation endpoint. Ensure necessary authorization checks are applied.

Edited Jan 18, 2024 by Leaminn Ma
Assignee Loading
Time tracking Loading