Commit 7dc28927 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'mirror-cleanup-in-project-destroy-service' into 'master'

Cleans up mirror capacity if project is a scheduled mirror

See merge request !2445
parents a5fceaa9 34aeb3b2
......@@ -6,9 +6,16 @@ module EE
super
mirror_cleanup(project)
log_geo_event(project)
end
def mirror_cleanup(project)
return unless project.mirror?
::Gitlab::Mirror.decrement_capacity(project.id)
end
def log_geo_event(project)
::Geo::RepositoryDeletedEventStore.new(project,
repo_path: repo_path,
......
---
title: Cleans up mirror capacity in project destroy service if project is a scheduled
mirror
merge_request: 2445
author:
......@@ -18,6 +18,19 @@ describe Projects::DestroyService, services: true do
stub_container_registry_tags(repository: :any, tags: [])
end
context 'when project is a mirror' do
it 'decrements capacity if mirror was scheduled' do
max_capacity = current_application_settings.mirror_max_capacity
project_mirror = create(:project, :mirror, :repository, :import_scheduled)
Gitlab::Mirror.increment_capacity(project_mirror.id)
expect do
Projects::DestroyService.new(project_mirror, project_mirror.owner, {}).execute
end.to change { Gitlab::Mirror.available_capacity }.from(max_capacity - 1).to(max_capacity)
end
end
context 'when running on a primary node' do
let!(:geo_node) { create(:geo_node, :primary, :current) }
......
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