Commit bd6fdc11 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '214092-gc-when-project-mirroring-fetches' into 'master'

Run project housekeeping for pull mirrors

See merge request gitlab-org/gitlab!46493
parents d545a0cd 6192cfdd
......@@ -42,6 +42,11 @@ module Projects
# Let's skip this if the repository hasn't changed.
update_lfs_objects if project.repository.checksum != checksum_before
# Running git fetch in the repository creates loose objects in the same
# way running git push *to* the repository does, so ensure we run regular
# garbage collection
run_housekeeping
success
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError, UpdateError => e
error(e.message)
......@@ -149,6 +154,15 @@ module Projects
end
end
def run_housekeeping
service = Projects::HousekeepingService.new(project)
service.increment!
service.execute if service.needed?
rescue Projects::HousekeepingService::LeaseTaken
# best-effort
end
# In Git is possible to tag blob objects, and those blob objects don't point to a Git commit so those tags
# have no target.
def repository_tags_with_target
......
---
title: Run project housekeeping for pull mirrors
merge_request: 46493
author:
type: performance
......@@ -30,6 +30,19 @@ RSpec.describe Projects::UpdateMirrorService do
service.execute
end
it 'runs project housekeeping' do
stub_fetch_mirror(project)
expect_next_instance_of(Projects::HousekeepingService) do |svc|
expect(svc.project).to eq(project)
expect(svc).to receive(:increment!)
expect(svc).to receive(:needed?).and_return(true)
expect(svc).to receive(:execute)
end
service.execute
end
it 'rescues exceptions from Repository#ff_merge' do
stub_fetch_mirror(project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment