Skip to content

gitserver: eventually re-clone after failed sg maintenance

Administrator requested to merge sh/set-log-file into main

Created by: stefanhengl

It is possible that sg maintenance fails on a corrupt repo. If this is the case, we keep running sg maintenance periodically until the repo is eventually fixed (either manually or due to a re-clone). However the time until re-clone can be very long and we should re-clone earlier if we know the repo is corrupt.

On dogfood we currently see such a case. sg maintenance fails for 1 repo with the error (...) refs/pull/138704/merge does not point to a valid object

Git's gc deals with this by placing a gc.log file in the git dir. This PR follows the same logic.

A failed sg maintenance run will place a log file in the git directory. Subsequent sg maintenance runs are skipped unless the log file is old. A successful run removes the log file.

If maybeReclone encounters the log file, it will re-clone the repo.

Test plan

added a unit test

Merge request reports

Loading