Make Housekeeping button do a full garbage collection
Previously the Housekeeping button and API would use the counter of last pushes to determine whether to do a full garbage collection, or whether to do one of the less comprehensive tasks: a full repack, incremental pack, or ref pack. This was confusing behavior, since a project owner might have to click the button dozens of times before a full GC would be initiated. This commit forces a full GC each time this is initiated. Note that the `ExclusiveLease` in `HousekeepingService` prevents users from clicking on the button more than once a day. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63349
This commit is contained in:
parent
38d46edba5
commit
d48ee86053
|
@ -182,7 +182,7 @@ class ProjectsController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
def housekeeping
|
||||
::Projects::HousekeepingService.new(@project).execute
|
||||
::Projects::HousekeepingService.new(@project, :gc).execute
|
||||
|
||||
redirect_to(
|
||||
project_path(@project),
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Make Housekeeping button do a full garbage collection
|
||||
merge_request: 30289
|
||||
author:
|
||||
type: fixed
|
|
@ -474,7 +474,7 @@ module API
|
|||
authorize_admin_project
|
||||
|
||||
begin
|
||||
::Projects::HousekeepingService.new(user_project).execute
|
||||
::Projects::HousekeepingService.new(user_project, :gc).execute
|
||||
rescue ::Projects::HousekeepingService::LeaseTaken => error
|
||||
conflict!(error.message)
|
||||
end
|
||||
|
|
|
@ -318,6 +318,53 @@ describe ProjectsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#housekeeping' do
|
||||
let(:group) { create(:group) }
|
||||
let(:project) { create(:project, group: group) }
|
||||
let(:housekeeping) { Projects::HousekeepingService.new(project) }
|
||||
|
||||
context 'when authenticated as owner' do
|
||||
before do
|
||||
group.add_owner(user)
|
||||
sign_in(user)
|
||||
|
||||
allow(Projects::HousekeepingService).to receive(:new).with(project, :gc).and_return(housekeeping)
|
||||
end
|
||||
|
||||
it 'forces a full garbage collection' do
|
||||
expect(housekeeping).to receive(:execute).once
|
||||
|
||||
post :housekeeping,
|
||||
params: {
|
||||
namespace_id: project.namespace.path,
|
||||
id: project.path
|
||||
}
|
||||
|
||||
expect(response).to have_gitlab_http_status(302)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when authenticated as developer' do
|
||||
let(:developer) { create(:user) }
|
||||
|
||||
before do
|
||||
group.add_developer(developer)
|
||||
end
|
||||
|
||||
it 'does not execute housekeeping' do
|
||||
expect(housekeeping).not_to receive(:execute)
|
||||
|
||||
post :housekeeping,
|
||||
params: {
|
||||
namespace_id: project.namespace.path,
|
||||
id: project.path
|
||||
}
|
||||
|
||||
expect(response).to have_gitlab_http_status(302)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
render_views
|
||||
|
||||
|
|
|
@ -2428,7 +2428,7 @@ describe API::Projects do
|
|||
let(:housekeeping) { Projects::HousekeepingService.new(project) }
|
||||
|
||||
before do
|
||||
allow(Projects::HousekeepingService).to receive(:new).with(project).and_return(housekeeping)
|
||||
allow(Projects::HousekeepingService).to receive(:new).with(project, :gc).and_return(housekeeping)
|
||||
end
|
||||
|
||||
context 'when authenticated as owner' do
|
||||
|
|
Loading…
Reference in New Issue