Commit 5e366b1a authored by Sean McGivern's avatar Sean McGivern

Make fetch worker forward-compatible

We will use this hook name in future, but with a better implementation.
parent d27c5f82
......@@ -3,7 +3,7 @@ class SystemHook < WebHook
Sidekiq::Client.enqueue(SystemHookWorker, id, data, hook_name)
end
def self.fetch_hooks
def self.repository_update_hooks
GeoNode.where(primary: false).map(&:system_hook)
end
end
# TODO: Remove me once Geo is fixed
class GeoRepositoryFetchWorker
include Sidekiq::Worker
include Gitlab::ShellAdapter
......
......@@ -9,8 +9,6 @@ class GeoRepositoryUpdateWorker
@project = Project.find(project_id)
@push_data = push_data
# TODO: Enable fetch once Geo is fixed
# fetch_repository(clone_url)
process_hooks if push_data # we should be compatible with old unprocessed data
end
......
......@@ -27,15 +27,16 @@ class PostReceive
# Triggers repository update on secondary nodes when Geo is enabled
Gitlab::Geo.notify_wiki_update(post_received.project) if Gitlab::Geo.enabled?
elsif post_received.regular_project?
# TODO: Remove this if block once Geo is fixed
# TODO: gitlab-org/gitlab-ce#26325. Remove this.
if Gitlab::Geo.enabled?
hook_data = {
event_name: 'repository_update',
project_id: post_received.project.id,
event_name: 'trigger_fetch',
project: project.hook_attrs,
remote_url: post_received.project.ssh_url_to_repo
}
SystemHooksService.new.execute_hooks(hook_data, :fetch_hooks)
SystemHooksService.new.execute_hooks(hook_data, :repository_update)
end
process_project_changes(post_received)
......
......@@ -24,7 +24,7 @@ module API
when 'key_create', 'key_destroy'
required_attributes! %w(key id)
::Geo::ScheduleKeyChangeService.new(params).execute
when 'trigger_fetch'
when 'repository_update'
required_attributes! %w(event_name project_id remote_url)
::Geo::ScheduleRepoFetchService.new(params).execute
when 'push'
......
require 'spec_helper'
# TODO: Remove me once Geo is fixed
describe GeoRepositoryFetchWorker do
describe '#perform' do
let(:project) { create(:empty_project) }
......
......@@ -30,27 +30,6 @@ describe GeoRepositoryUpdateWorker do
expect(Project).to receive(:find).at_least(:once).with(project.id) { project }
end
context 'when no repository' do
before do
allow(project.repository).to receive(:fetch_geo_mirror)
allow(project).to receive(:repository_exists?) { false }
end
# TODO: Enable again once Geo update has been properly fixed.
# See !1015 for more info
xit 'creates a new repository' do
expect(project).to receive(:create_repository)
performed
end
xit 'executes after_create hook' do
expect(project.repository).to receive(:after_create)
performed
end
end
context 'when empty repository' do
before do
allow(project.repository).to receive(:fetch_geo_mirror)
......
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