Add gitlab:keep_around:orphaned raketask

What does this MR do and why?

#475246 (closed)

This raketask is designed to help detect orphaned keep-around references that might be safe to remove.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Run the raketask (updating the project path to match a project in your GDK):
    $ bundle exec rake gitlab:keep_around:orphaned FILENAME=orphaned.csv PROJECT_PATH=root/cool-project
    I, [2024-08-27T16:35:39.308775 #178111]  INFO -- : Finding keep-around references...
    I, [2024-08-27T16:35:39.340035 #178111]  INFO -- : Found 7 keep-around references
    I, [2024-08-27T16:35:39.340084 #178111]  INFO -- : Checking pipeline shas...
    I, [2024-08-27T16:35:39.498847 #178111]  INFO -- : Checking merge request shas...
    I, [2024-08-27T16:35:39.532272 #178111]  INFO -- : Checking merge request diff shas...
    I, [2024-08-27T16:35:39.566079 #178111]  INFO -- : Checking diff note shas...
    I, [2024-08-27T16:35:39.628785 #178111]  INFO -- : Checking note shas...
    I, [2024-08-27T16:35:39.631355 #178111]  INFO -- : Checking sent notification shas...
    I, [2024-08-27T16:35:39.640706 #178111]  INFO -- : Checking todo shas...
    I, [2024-08-27T16:35:39.660778 #178111]  INFO -- : Summary:
    I, [2024-08-27T16:35:39.660843 #178111]  INFO -- : 	Keep-around references: 7
    I, [2024-08-27T16:35:39.660878 #178111]  INFO -- : 	Potentially orphaned: 2
    I, [2024-08-27T16:35:39.660900 #178111]  INFO -- : Writing CSV...
    I, [2024-08-27T16:35:39.660976 #178111]  INFO -- : Keep-around orphan report complete
  2. Check the contents of the report CSV (the first column is the reference name, the second column is how many DB records point to it):
    $ cat orphaned.csv 
    keep_around,count
    refs/keep-around/02c1656bfc38a697a89d76bbfe29f3eb88b87ffc,1
    refs/keep-around/236fec6774788de068fb63e62e98971aa511a8ab,2
    refs/keep-around/5293981aeeea286cc1d0acee6e472172845ca543,5
    refs/keep-around/875bae757a1823ad9668b9952791f55fb9448f6b,0
    refs/keep-around/aeec65ae9a7eb256b4998d90126e0e03af7b77fe,0
    refs/keep-around/d2f609ed3f07d0efc8fc557044795743ab334527,2
    refs/keep-around/f80ec752b6bc8db25bb71d77395a7129469872c3,1
  3. Do something that would create a new keep-around. E.g. create a new merge request by updating something in the UI.
  4. Re-run the report and note that there are now differences 🎉
Edited by James Fargher

Merge request reports

Loading