Backfill wiki repositories

parent 8f05852c
...@@ -10,7 +10,7 @@ module Geo ...@@ -10,7 +10,7 @@ module Geo
def execute def execute
try_obtain_lease do try_obtain_lease do
synchronize do |started_at, finished_at| fetch_repositories do |started_at, finished_at|
registry = Geo::ProjectRegistry.find_or_create_by(project_id: project.id) registry = Geo::ProjectRegistry.find_or_create_by(project_id: project.id)
registry.last_repository_synced_at = started_at registry.last_repository_synced_at = started_at
registry.last_repository_successful_sync_at = finished_at if finished_at registry.last_repository_successful_sync_at = finished_at if finished_at
...@@ -21,7 +21,7 @@ module Geo ...@@ -21,7 +21,7 @@ module Geo
private private
def synchronize def fetch_repositories
started_at = DateTime.now started_at = DateTime.now
finished_at = nil finished_at = nil
...@@ -29,6 +29,12 @@ module Geo ...@@ -29,6 +29,12 @@ module Geo
project.create_repository unless project.repository_exists? project.create_repository unless project.repository_exists?
project.repository.after_create if project.empty_repo? project.repository.after_create if project.empty_repo?
project.repository.fetch_geo_mirror(ssh_url_to_repo) project.repository.fetch_geo_mirror(ssh_url_to_repo)
# Second .wiki call returns a Gollum::Wiki, and it will always create the physical repository when not found
if project.wiki_enabled? && project.wiki.wiki.exist?
project.wiki.repository.fetch_geo_mirror(ssh_url_to_wiki)
end
project.repository.expire_all_method_caches project.repository.expire_all_method_caches
project.repository.expire_branch_cache project.repository.expire_branch_cache
project.repository.expire_content_cache project.repository.expire_content_cache
...@@ -59,8 +65,16 @@ module Geo ...@@ -59,8 +65,16 @@ module Geo
@key ||= "repository_backfill_service:#{project.id}" @key ||= "repository_backfill_service:#{project.id}"
end end
def primary_ssh_path_prefix
Gitlab::Geo.primary_ssh_path_prefix
end
def ssh_url_to_repo def ssh_url_to_repo
"#{Gitlab::Geo.primary_ssh_path_prefix}#{project.path_with_namespace}.git" "#{primary_ssh_path_prefix}#{project.path_with_namespace}.git"
end
def ssh_url_to_wiki
"#{primary_ssh_path_prefix}#{project.path_with_namespace}.wiki.git"
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