Commit beff16e3 authored by nmilojevic1's avatar nmilojevic1

Disable object_storage for export task

- log error if there are import_export_shared errors
- extract disable_upload_object_storage for both import and export task
parent 8939a6b5
...@@ -26,6 +26,24 @@ module Gitlab ...@@ -26,6 +26,24 @@ module Gitlab
} }
end end
def disable_upload_object_storage
overwrite_uploads_setting('background_upload', false) do
overwrite_uploads_setting('direct_upload', false) do
yield
end
end
end
def overwrite_uploads_setting(key, value)
old_value = Settings.uploads.object_store[key]
Settings.uploads.object_store[key] = value
yield
ensure
Settings.uploads.object_store[key] = old_value
end
def success(message) def success(message)
logger.info(message) logger.info(message)
......
...@@ -19,6 +19,8 @@ module Gitlab ...@@ -19,6 +19,8 @@ module Gitlab
.execute(Gitlab::ImportExport::AfterExportStrategies::MoveFileStrategy.new(archive_path: file_path), measurement_options) .execute(Gitlab::ImportExport::AfterExportStrategies::MoveFileStrategy.new(archive_path: file_path), measurement_options)
end end
return error(project.import_export_shared.errors.join(', ')) if project.import_export_shared.errors.any?
success('Done!') success('Done!')
end end
...@@ -32,8 +34,13 @@ module Gitlab ...@@ -32,8 +34,13 @@ module Gitlab
def with_export def with_export
with_request_store do with_request_store do
::Gitlab::GitalyClient.allow_n_plus_1_calls do # We are disabling ObjectStorage for `export`
yield # since when direct upload is enabled, remote storage will be used
# and Gitlab::ImportExport::AfterExportStrategies::MoveFileStrategy will fail to copy exported archive
disable_upload_object_storage do
::Gitlab::GitalyClient.allow_n_plus_1_calls do
yield
end
end end
end end
end end
......
...@@ -67,24 +67,6 @@ module Gitlab ...@@ -67,24 +67,6 @@ module Gitlab
Sidekiq::Worker.drain_all Sidekiq::Worker.drain_all
end end
def disable_upload_object_storage
overwrite_uploads_setting('background_upload', false) do
overwrite_uploads_setting('direct_upload', false) do
yield
end
end
end
def overwrite_uploads_setting(key, value)
old_value = Settings.uploads.object_store[key]
Settings.uploads.object_store[key] = value
yield
ensure
Settings.uploads.object_store[key] = old_value
end
def full_path def full_path
"#{namespace.full_path}/#{project_path}" "#{namespace.full_path}/#{project_path}"
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