Use OptimizeRepository and PruneUnreachableObjects for housekeeping
What does this MR do and why?
Related issue: #352385 (closed)
A single OptimizeRepository has been introduced instead of deprecated RPCs:
- GarbageCollect
- RepackIncremental
- RepackFull
- PackRefs
Garbage collect with prune option is replaced with PruneUnreachableObjects RPC.
The idea for the first iteration is to call OptimizeRepository RPC when any of the deprecated RPCs is requested to be called.
We call the deprecated RPCs from a single place: GitGarbageCollectMethods. This module is included into worker classes, i.e this code is being called by workers only. It's important because OptimizeRepository RPC call may take minutes to finish but usually executes fast.
The functionality is put behind a feature flag: optimized_housekeeping (rollout issue: #353607 (closed)).
One of the tricky parts of this first iteration is that we have housekeeping options. If we replace the deprecated RPCs with a single one in the background, the options are no longer respected. It means that we lie to a user who customized these options. In this case, it makes sense to enable the feature flag by default only when the UX is changed, i.e the &7629 (closed) is completed.
How to verify
We can verify that the correct RPC is called in Gitaly logs (for example, from gdk folder tail -f log/praefect/current), when housekeeping service is called from Rails console:
Repositories::HousekeepingService.new(project).execute
- When
optimized_housekeepingis disabled, a deprecated RPC (for example,GarbageCollect) - When
optimized_housekeepingis enabled,OptimizeRepositoryRPC is called