Skip to content

[gitserver] Initial version of removing repo directories that are not defined in Postgres

Administrator requested to merge milan/cleanup_non_existing_repos into main

Created by: kopancek

Description

This PR is meant to cleanup the mess I have created on dotcom by manually removing repos from the DB with an SQL command. Instead of soft delete I did a hard delete, which seems to cause the repositories never to be removed from disk.

I think this new behavior is actually beneficial and can remove stale data from the disks, in case other inconsistencies between current disk state and what's defined in the DB exist.

Screenshot

This is how the new metric looks like in the grafana dashboard: Screenshot 2022-08-09 at 18 08 03

Test plan

This feature is behind an env flag SRC_REMOVE_NON_EXISTING_REPOS which by default is false.

So far tested locally and it seems to be working fine in these scenarios:

  1. Flag is not set - nothing happened
  2. Flag is set to false - nothing happened
  3. Flag is set to true - removed repositories, that were on disk, but not defined in the DB
  4. Flag is set to true, 2nd run - nothing happened
  5. Flag is set to true, deleted a row in the repo table - repo deleted from disk as well

Change has unit tests attached as well.

Merge request reports

Loading