Commit 654509d7 authored by Stan Hu's avatar Stan Hu

Merge branch...

Merge branch '6888-geo-project-imports-may-not-be-synced-if-repository-takes-some-time-to-fetch' into 'master'

Resync project repositories on secondaries nodes when import finishes

See merge request gitlab-org/gitlab-ee!6529
parents 3fd62a46 250b71cc
...@@ -503,6 +503,12 @@ module EE ...@@ -503,6 +503,12 @@ module EE
end end
request_cache(:any_path_locks?) { self.id } request_cache(:any_path_locks?) { self.id }
override :after_import
def after_import
super
log_geo_events
end
private private
def set_override_pull_mirror_available def set_override_pull_mirror_available
...@@ -538,5 +544,12 @@ module EE ...@@ -538,5 +544,12 @@ module EE
def validate_board_limit(board) def validate_board_limit(board)
# Board limits are disabled in EE, so this method is just a no-op. # Board limits are disabled in EE, so this method is just a no-op.
end end
def log_geo_events
return unless ::Gitlab::Geo.primary?
::Geo::RepositoryUpdatedService.new(self, source: ::Geo::RepositoryUpdatedEvent::REPOSITORY).execute
::Geo::RepositoryUpdatedService.new(self, source: ::Geo::RepositoryUpdatedEvent::WIKI).execute
end
end end
end end
---
title: Resync project repositories on secondaries nodes when import finishes
merge_request: 6529
author:
type: fixed
...@@ -1481,4 +1481,40 @@ describe Project do ...@@ -1481,4 +1481,40 @@ describe Project do
expect(project.latest_pipeline_with_security_reports).to eq(pipeline_2) expect(project.latest_pipeline_with_security_reports).to eq(pipeline_2)
end end
end end
describe '#after_import' do
let(:project) { create(:project) }
let(:repository_updated_service) { instance_double('::Geo::RepositoryUpdatedService') }
let(:wiki_updated_service) { instance_double('::Geo::RepositoryUpdatedService') }
before do
allow(::Geo::RepositoryUpdatedService)
.to receive(:new)
.with(project, source: Geo::RepositoryUpdatedEvent::REPOSITORY)
.and_return(repository_updated_service)
allow(::Geo::RepositoryUpdatedService)
.to receive(:new)
.with(project, source: Geo::RepositoryUpdatedEvent::WIKI)
.and_return(wiki_updated_service)
end
it 'calls Geo::RepositoryUpdatedService when running on a Geo primary node' do
allow(Gitlab::Geo).to receive(:primary?).and_return(true)
expect(repository_updated_service).to receive(:execute).once
expect(wiki_updated_service).to receive(:execute).once
project.after_import
end
it 'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node' do
allow(Gitlab::Geo).to receive(:primary?).and_return(false)
expect(repository_updated_service).not_to receive(:execute)
expect(wiki_updated_service).not_to receive(:execute)
project.after_import
end
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