Commit 3ec71075 authored by Valery Sizov's avatar Valery Sizov

Geo Add forced redownload for some type of errors[ci skip]

parent c598cd87
......@@ -66,13 +66,18 @@ module Geo
end
def should_be_retried?
return false if registry.public_send("force_to_redownload_#{type}")
retry_count <= RETRY_BEFORE_REDOWNLOAD
end
def should_be_redownloaded?
return true if registry.public_send("force_to_redownload_#{type}")
(RETRY_BEFORE_REDOWNLOAD..RETRY_LIMIT) === retry_count
end
# Progressive backoff
def delay(retry_count = 0)
(retry_count ** 4) + 15 + (rand(30) * (retry_count + 1))
end
......
......@@ -42,6 +42,7 @@ module Geo
log_error('Error syncing repository', e)
rescue Gitlab::Git::Repository::NoRepository => e
log_error('Invalid repository', e)
registry.update(force_to_redownload_repository: true)
log_info('Expiring caches')
project.repository.after_create
ensure
......
......@@ -34,12 +34,14 @@ module Geo
log_info('Finished wiki sync',
update_delay_s: update_delay_in_seconds,
download_time_s: download_time_in_seconds)
rescue Gitlab::Git::Repository::NoRepository,
Gitlab::Git::RepositoryMirroring::RemoteError,
rescue Gitlab::Git::RepositoryMirroring::RemoteError,
Gitlab::Shell::Error,
ProjectWiki::CouldNotCreateWikiError,
Geo::EmptyCloneUrlPrefixError => e
log_error('Error syncing wiki repository', e)
rescue Gitlab::Git::Repository::NoRepository => e
log_error('Invalid wiki', e)
registry.update(force_to_redownload_wiki: true)
ensure
# Backup can only exist if redownload was unsuccessful
if with_backup && File.exist?(backup_path)
......
class AddRetryCountFieldsToRegistries < ActiveRecord::Migration
def change
add_column :file_registry, :retry_count, :integer
add_column :project_registry, :repository_retry_count, :integer
add_column :project_registry, :wiki_retry_count, :integer
add_column :file_registry, :retry_at, :datetime
add_column :project_registry, :repository_retry_count, :integer
add_column :project_registry, :repository_retry_at, :datetime
add_column :project_registry, :force_to_redownload_repository, :boolean
add_column :project_registry, :wiki_retry_count, :integer
add_column :project_registry, :wiki_retry_at, :datetime
add_column :file_registry, :retry_at, :datetime
add_column :project_registry, :force_to_redownload_wiki, :boolean
end
end
......@@ -44,9 +44,11 @@ ActiveRecord::Schema.define(version: 20171101105200) do
t.datetime "last_wiki_synced_at"
t.datetime "last_wiki_successful_sync_at"
t.integer "repository_retry_count"
t.integer "wiki_retry_count"
t.datetime "repository_retry_at"
t.boolean "force_to_redownload_repository"
t.integer "wiki_retry_count"
t.datetime "wiki_retry_at"
t.boolean "force_to_redownload_wiki"
end
add_index "project_registry", ["last_repository_successful_sync_at"], name: "index_project_registry_on_last_repository_successful_sync_at", using: :btree
......
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