Does not sync blobs on Object Storage when is not enabled

Add some checks to skip file transfers on a Geo secondary
node when file is stored on Object Storage but syncing
object storage is disabled or the object storage is
not configure for the data type on the secondary node.
parent 5495964c
...@@ -87,11 +87,27 @@ module Gitlab ...@@ -87,11 +87,27 @@ module Gitlab
unless ensure_destination_path_exists unless ensure_destination_path_exists
return failure_result(reason: 'Skipping transfer as we cannot create the destination directory') return failure_result(reason: 'Skipping transfer as we cannot create the destination directory')
end end
else
unless sync_object_storage_enabled?
return failure_result(reason: 'Skipping transfer as this secondary node is not allowed to replicate content on Object Storage')
end
unless object_store_enabled?
return failure_result(reason: "Skipping transfer as this secondary node is not configured to store #{replicator.replicable_name} on Object Storage")
end
end end
nil nil
end end
def sync_object_storage_enabled?
Gitlab::Geo.current_node.sync_object_storage
end
def object_store_enabled?
carrierwave_uploader.class.object_store_enabled?
end
def absolute_path def absolute_path
carrierwave_uploader.path carrierwave_uploader.path
end end
......
...@@ -52,6 +52,40 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do ...@@ -52,6 +52,40 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do
xit 'ensures the file destination directory exists' # Not worth testing here as-is. Extract the functionality first. xit 'ensures the file destination directory exists' # Not worth testing here as-is. Extract the functionality first.
end end
context 'when the file is on Object Storage' do
before do
stub_package_file_object_storage(enabled: true, direct_upload: true)
end
let!(:model_record) { create(:package_file, :npm, :object_storage) }
subject { described_class.new(replicator: model_record.replicator) }
context 'with object storage sync disabled' do
before do
secondary.update_column(:sync_object_storage, false)
end
it 'returns failure' do
result = subject.execute
expect(result.success).to be_falsey
end
end
context 'with object storage disabled' do
before do
stub_package_file_object_storage(enabled: false)
end
it 'returns failure' do
result = subject.execute
expect(result.success).to be_falsey
end
end
end
end end
context 'when an error occurs while getting a Tempfile' do context 'when an error occurs while getting a Tempfile' do
......
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