Commit 52bb5648 authored by James Lopez's avatar James Lopez

squashed - fix timing issues in prod importing projects

added changelog

fix specs

refactored code based on feedback

fix rubocop warning
parent 2f344eca
...@@ -41,6 +41,7 @@ v 8.10.3 (unreleased) ...@@ -41,6 +41,7 @@ v 8.10.3 (unreleased)
- Fix hooks missing on imported GitLab projects - Fix hooks missing on imported GitLab projects
- Properly abort a merge when merge conflicts occur - Properly abort a merge when merge conflicts occur
- Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured. - Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured.
- Fix timing problems running imports on production
v 8.10.2 v 8.10.2
- User can now search branches by name. !5144 - User can now search branches by name. !5144
......
...@@ -3,6 +3,8 @@ module Gitlab ...@@ -3,6 +3,8 @@ module Gitlab
class FileImporter class FileImporter
include Gitlab::ImportExport::CommandLineUtil include Gitlab::ImportExport::CommandLineUtil
MAX_RETRIES = 8
def self.import(*args) def self.import(*args)
new(*args).import new(*args).import
end end
...@@ -14,7 +16,10 @@ module Gitlab ...@@ -14,7 +16,10 @@ module Gitlab
def import def import
FileUtils.mkdir_p(@shared.export_path) FileUtils.mkdir_p(@shared.export_path)
decompress_archive
wait_for_archived_file do
decompress_archive
end
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
...@@ -22,6 +27,19 @@ module Gitlab ...@@ -22,6 +27,19 @@ module Gitlab
private private
# Exponentially sleep until I/O finishes copying the file
def wait_for_archived_file
MAX_RETRIES.times do |retry_number|
if File.exist?(@archive_file)
yield
break
else
sleep(2**retry_number)
end
end
end
def decompress_archive def decompress_archive
result = untar_zxf(archive: @archive_file, dir: @shared.export_path) result = untar_zxf(archive: @archive_file, dir: @shared.export_path)
......
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