Commit 58397d10 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-geo-fix-file-download-errors' into 'master'

Geo: Properly check return value of file download return codes

Closes #3749

See merge request gitlab-org/gitlab-ee!3143
parents f797d84c b1664a69
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
try_obtain_lease do |lease| try_obtain_lease do |lease|
start_time = Time.now start_time = Time.now
bytes_downloaded = downloader.execute bytes_downloaded = downloader.execute
success = bytes_downloaded && bytes_downloaded >= 0 success = (bytes_downloaded.present? && bytes_downloaded >= 0)
log_info("File download", log_info("File download",
success: success, success: success,
bytes_downloaded: bytes_downloaded, bytes_downloaded: bytes_downloaded,
......
...@@ -30,6 +30,12 @@ describe Geo::FileDownloadService do ...@@ -30,6 +30,12 @@ describe Geo::FileDownloadService do
expect { execute! }.to change { Geo::FileRegistry.failed.count }.by(1) expect { execute! }.to change { Geo::FileRegistry.failed.count }.by(1)
end end
it 'registers when the download fails with some other error' do
stub_transfer(Gitlab::Geo::FileTransfer, nil)
expect { execute! }.to change { Geo::FileRegistry.failed.count }.by(1)
end
end end
context 'group avatar' do context 'group avatar' do
......
...@@ -62,6 +62,7 @@ describe Geo::FileDownloadDispatchWorker, :postgresql do ...@@ -62,6 +62,7 @@ describe Geo::FileDownloadDispatchWorker, :postgresql do
it 'attempts to load a new batch without pending downloads' do it 'attempts to load a new batch without pending downloads' do
stub_const('Geo::BaseSchedulerWorker::DB_RETRIEVE_BATCH_SIZE', 5) stub_const('Geo::BaseSchedulerWorker::DB_RETRIEVE_BATCH_SIZE', 5)
stub_const('Geo::BaseSchedulerWorker::MAX_CAPACITY', 2) stub_const('Geo::BaseSchedulerWorker::MAX_CAPACITY', 2)
allow_any_instance_of(::Gitlab::Geo::Transfer).to receive(:download_from_primary).and_return(100)
avatar = fixture_file_upload(Rails.root.join('spec/fixtures/dk.png')) avatar = fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'))
create_list(:lfs_object, 2, :with_file) create_list(:lfs_object, 2, :with_file)
......
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