Commit ae2f45b6 authored by Valery Sizov's avatar Valery Sizov

Merge branch 'sh-fix-wiki-resync' into 'master'

Geo: Fix Wiki resync when Wiki repository does not exist

Closes #5218

See merge request gitlab-org/gitlab-ee!4927
parents f7da03dd 61a36b46
...@@ -205,7 +205,10 @@ module Geo ...@@ -205,7 +205,10 @@ module Geo
# Make sure we have a namespace directory # Make sure we have a namespace directory
gitlab_shell.add_namespace(project.repository_storage_path, deleted_disk_path_temp) gitlab_shell.add_namespace(project.repository_storage_path, deleted_disk_path_temp)
if project.repository_exists? && !gitlab_shell.mv_repository(project.repository_storage_path, repository.disk_path, deleted_disk_path_temp) # Make sure we have the most current state of exists?
repository.expire_exists_cache
if repository.exists? && !gitlab_shell.mv_repository(project.repository_storage_path, repository.disk_path, deleted_disk_path_temp)
raise Gitlab::Shell::Error, 'Can not move original repository out of the way' raise Gitlab::Shell::Error, 'Can not move original repository out of the way'
end end
......
...@@ -24,6 +24,7 @@ module Geo ...@@ -24,6 +24,7 @@ module Geo
fail_registry!('Invalid wiki', e, force_to_redownload_wiki: true) fail_registry!('Invalid wiki', e, force_to_redownload_wiki: true)
ensure ensure
clean_up_temporary_repository if redownload clean_up_temporary_repository if redownload
expire_repository_caches
end end
def ssh_url_to_wiki def ssh_url_to_wiki
...@@ -38,6 +39,11 @@ module Geo ...@@ -38,6 +39,11 @@ module Geo
project.wiki.ensure_repository project.wiki.ensure_repository
end end
def expire_repository_caches
log_info('Expiring caches')
repository.after_sync
end
def mark_sync_as_successful def mark_sync_as_successful
update_registry!(finished_at: DateTime.now, attrs: { last_wiki_sync_failure: nil }) update_registry!(finished_at: DateTime.now, attrs: { last_wiki_sync_failure: nil })
......
---
title: 'Geo: Fix Wiki resync when Wiki repository does not exist'
merge_request:
author:
type: fixed
...@@ -309,6 +309,9 @@ describe Geo::RepositorySyncService do ...@@ -309,6 +309,9 @@ describe Geo::RepositorySyncService do
force_to_redownload_repository: true force_to_redownload_repository: true
) )
expect(project.repository).to receive(:expire_exists_cache).twice.and_call_original
expect(subject).not_to receive(:fail_registry!)
subject.execute subject.execute
end end
end end
......
...@@ -170,6 +170,23 @@ RSpec.describe Geo::WikiSyncService do ...@@ -170,6 +170,23 @@ RSpec.describe Geo::WikiSyncService do
expect(registry.last_wiki_sync_failure).to eq('Error syncing wiki repository: shell error') expect(registry.last_wiki_sync_failure).to eq('Error syncing wiki repository: shell error')
end end
end end
context 'no Wiki repository' do
let(:project) { create(:project, :repository) }
it 'does not raise an error' do
create(
:geo_project_registry,
project: project,
force_to_redownload_wiki: true
)
expect(project.wiki.repository).to receive(:expire_exists_cache).twice.and_call_original
expect(subject).not_to receive(:fail_registry!)
subject.execute
end
end
end end
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