Skip to content

LFS reference cleanup task does not take design management or project wikis into account

Summary

Spotted while rolling out this feature flag: #238605 (comment 406261386) :cleanup_lfs_during_gc

GitLab has the gitlab:cleanup:orphan_lfs_file_references rake task: https://docs.gitlab.com/ee/raketasks/cleanup/

In !38813 (merged) , we linked the rake task code to the git gc operation.

While rolling out the feature flag, it occurred to me that design management repository adds LFS objects to the project, but we only consult the project repository. This means that both the automatic and manual routes will remove references to LFS objects held by the design repository, breaking access and resulting in data loss in the designs.

Steps to reproduce

  • Enable :cleanup_lfs_during_gc feature flag
  • Add a design to an issue in a project
  • Add an LFS object to the project wiki
  • Run project housekeeping

What is the current bug behavior?

Trying to view the raw image for the design will give a 404 once housekeeping is complete

What is the expected correct behavior?

Housekeeping should not delete LFS objects that are in use. It needs to take design management and the project wiki into account. We should also make doubly sure that any other potential LFS-using repositories are taken into account.

Possible fixes

We get a list of LFS objects used by the main repository here: lib/gitlab/cleanup/orphan_lfs_file_references.rb

Perhaps we just need to add the design management (and other, if needed) repositories to the scan?

Edited by Nick Thomas