Commit 65867a35 authored by Douwe Maan's avatar Douwe Maan Committed by Clement Ho

Merge branch '2635-geo-no-repository-for-such-path' into 'master'

Geo: prevent Gitlab::Git::Repository::NoRepository from stucking replication

Closes #2635

See merge request !2115
parent 40f490ed
Pipeline #9143086 (#) passed with stages
in 104 minutes and 7 seconds
......@@ -38,6 +38,10 @@ module Geo
finished_at = DateTime.now
rescue Gitlab::Shell::Error => e
Rails.logger.error("#{self.class.name}: Error syncing repository for project #{project.path_with_namespace}: #{e}")
rescue Gitlab::Git::Repository::NoRepository => e
Rails.logger.error("#{self.class.name}: Error invalid repository for project #{project.path_with_namespace}: #{e}")
log('Expiring caches')
project.repository.after_create
end
[started_at, finished_at]
......
......@@ -21,7 +21,11 @@ module Geo
project.repository.expire_content_cache
end
rescue Gitlab::Shell::Error => e
logger.error "Error fetching repository for project #{project.path_with_namespace}: #{e}"
logger.error "#{self.class.name}: Error fetching repository for project #{project.path_with_namespace}: #{e}"
rescue Gitlab::Git::Repository::NoRepository => e
logger.error "#{self.class.name}: Error invalid repository for project #{project.path_with_namespace}: #{e}"
logger.warn "#{self.class.name}: Invalidating cache for project #{project.path_with_namespace}"
project.repository.after_create
end
private
......
---
title: 'Geo: prevent Gitlab::Git::Repository::NoRepository from stucking replication'
merge_request: 2115
author:
......@@ -205,5 +205,26 @@ describe Geo::RepositorySyncService, services: true do
end
end
end
context 'when Gitlab::Shell::Error is raised' do
let(:project) { create(:empty_project) }
it 'rescues exception' do
expect(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error
end
end
context 'when Gitlab::Git::Repository::NoRepository is raised' do
let(:project) { create(:empty_project) }
it 'rescues exception and fires after_create hook' do
expect(subject).to receive(:fetch_project_repository).and_raise(Gitlab::Git::Repository::NoRepository)
expect_any_instance_of(Repository).to receive(:after_create)
expect { subject.execute }.not_to raise_error
end
end
end
end
......@@ -50,10 +50,17 @@ describe Geo::RepositoryUpdateService, services: true do
subject.execute
end
it 'does not raise exception when git failures occurs' do
it 'rescues Gitlab::Shell::Error failures' do
expect(project.repository).to receive(:fetch_geo_mirror).and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error
end
it 'rescues Gitlab::Git::Repository::NoRepository failures and fires after_create hook' do
expect(project.repository).to receive(:fetch_geo_mirror).and_raise(Gitlab::Git::Repository::NoRepository)
expect_any_instance_of(Repository).to receive(:after_create)
expect { subject.execute }.not_to raise_error
end
end
end
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