Need endpoint for clearing the repos directory on a shard
In order to complete the restore path in #749 (closed), we need some way of clearing out all existing repos on a shard.
The current non-gitaly approach is to move all the contents of the directory to a tmp location. (https://gitlab.com/gitlab-org/gitlab-ce/blob/v10.7.0/lib/backup/repository.rb#L81)
This allows us to restore your repositories, and not have any lingering repos that may have existing before your restore.
We need something that achieves the same result. There is a MR in place already that implements most of the rest of the restore through existing gitaly endpoints, and the beginnings of this issue were first discussed there: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18644#note_71942694
Some ideas that were already presented so far include:
- simply added a remove/clear repositories option to gitaly
- implement a move shard repositories, to move the existing repos to another location on the gitaly node's filesystem (essentially recreating what the code current tries)
- provide a new backup shard repos option that operates on the whole directory, rather than individual repos.
- To meet our criteria we would still need a way to clear the existing location
- provide a method for listing all existing repos in a chart (that does not rely on the gitlab db for project information) and leave it up to the backup client to move or remove each repo individually
Anything solution that allows us to clean out the repos directory should allow us to move forward.