Skip to content

Only trigger housekeeping once per push

James Fargher requested to merge fix_housekeeping_trigger into master

What does this MR do and why?

#25536 (closed)

Hoists the housekeeping logic from BranchPushService into the only class that uses it ProcessRefChangesService so that housekeeping is only called once per push and to make sure it is called for tag only pushes also.

The only other uses of BranchPushService are in specs, so there should be no risk of not calling house keeping where we used to.

How to set up and validate locally

There's no direct way to see if housekeeping has run since there are lots of configurations controlling it, but we can see if the counter was incremented.

  1. Clone a repo you have push access to from GDK.
  2. Find the repo in rails console and check pushes_since_gc:
    [1] pry(main)> Project.find(21).pushes_since_gc
    => 1
  3. Make a bunch of branches.
    $ git checkout -b branch1
    Switched to a new branch 'branch1'
    $ git checkout -b branch2
    Switched to a new branch 'branch2'
    $ git checkout -b branch3
    Switched to a new branch 'branch3'
  4. Push all the branches at once.
    $ git push origin branch1 branch2 branch3
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote: 
    remote: To create a merge request for branch1, visit:
    remote:   http://127.0.0.1:3000/root/banana/-/merge_requests/new?merge_request%5Bsource_branch%5D=branch1
    remote: 
    remote: 
    remote: To create a merge request for branch2, visit:
    remote:   http://127.0.0.1:3000/root/banana/-/merge_requests/new?merge_request%5Bsource_branch%5D=branch2
    remote: 
    remote: 
    remote: To create a merge request for branch3, visit:
    remote:   http://127.0.0.1:3000/root/banana/-/merge_requests/new?merge_request%5Bsource_branch%5D=branch3
    remote: 
    To ssh://127.0.0.1:2222/root/banana.git
     * [new branch]      branch1 -> branch1
     * [new branch]      branch2 -> branch2
     * [new branch]      branch3 -> branch3
  5. Check the projects pushes_since_gc again to make sure it's gone up by one:
    [1] pry(main)> Project.find(21).pushes_since_gc
    => 2

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Fargher

Merge request reports

Loading