提交 57cba4d1 编写于 作者: D Douglas Barbosa Alexandre

Merge branch 'sh-force-gc-after-import' into 'master'

Force a full GC after importing a project

Closes #59477

See merge request gitlab-org/gitlab-ce!26803
......@@ -9,7 +9,7 @@ module Projects
end
def execute
Projects::HousekeepingService.new(@project).execute do
Projects::HousekeepingService.new(@project, :gc).execute do
repository.delete_all_refs_except(RESERVED_REF_PREFIXES)
end
rescue Projects::HousekeepingService::LeaseTaken => e
......
......@@ -18,8 +18,9 @@ module Projects
end
end
def initialize(project)
def initialize(project, task = nil)
@project = project
@task = task
end
def execute
......@@ -69,6 +70,8 @@ module Projects
end
def task
return @task if @task
if pushes_since_gc % gc_period == 0
:gc
elsif pushes_since_gc % full_repack_period == 0
......
---
title: Force a full GC after importing a project
merge_request: 26803
author:
type: performance
......@@ -13,7 +13,7 @@ describe Projects::AfterImportService do
describe '#execute' do
before do
allow(Projects::HousekeepingService)
.to receive(:new).with(project).and_return(housekeeping_service)
.to receive(:new).with(project, :gc).and_return(housekeeping_service)
allow(housekeeping_service)
.to receive(:execute).and_yield
......
......@@ -88,6 +88,19 @@ describe Projects::HousekeepingService do
expect(project.pushes_since_gc).to eq(1)
end
end
it 'runs the task specifically requested' do
housekeeping = described_class.new(project, :gc)
allow(housekeeping).to receive(:try_obtain_lease).and_return(:gc_uuid)
allow(housekeeping).to receive(:lease_key).and_return(:gc_lease_key)
expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :gc_lease_key, :gc_uuid).twice
2.times do
housekeeping.execute
end
end
end
describe '#needed?' do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册