Commit 1f1a199b authored by Douwe Maan's avatar Douwe Maan

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
parents 45efbff1 7710235e
......@@ -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