diff options
author | Stan Hu <stanhu@gmail.com> | 2017-06-01 13:15:46 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-06-04 21:51:59 -0700 |
commit | 37dd073782520f70d021e8ca9960e0a1c9696129 (patch) | |
tree | 6f22e45c5cd7b9d836502a3f4bada0e0e5b325fe /spec/uploaders | |
parent | 39340e428e3546d3749498ce10b19ae6cda0e646 (diff) | |
download | gitlab-ce-37dd073782520f70d021e8ca9960e0a1c9696129.tar.gz |
Fix LFS timeouts when trying to save large filessh-fix-lfs-from-moving-across-filesystems
The following was happening:
1. Workhorse stores an LFS file in /var/opt/gitlab/gitlab-rails/shared/lfs-objects
2. CarrierWave then renames the file to a temporary directory (e.g. /opt/gitlab/embedded/service/gitlab-rails/tmp)
3. CarrierWave then renames the file to its final location (e.g. /var/opt/gitlab/gitlab-rails/shared/lfs-objects)
When the LFS upload path was on a different filesystem than the Rails
installation, step 2 could take a longer than 10 seconds, at which point Workhorse
would time out with "badgateway: failed after 10s: context canceled".
This change makes the work path in the same root as the LFS storage path, preventing moves
across filesystems.
Closes #33218
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/lfs_object_uploader_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/uploaders/lfs_object_uploader_spec.rb b/spec/uploaders/lfs_object_uploader_spec.rb new file mode 100644 index 00000000000..c3b72e7d677 --- /dev/null +++ b/spec/uploaders/lfs_object_uploader_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe LfsObjectUploader do + let(:uploader) { described_class.new(build_stubbed(:empty_project)) } + + describe '#cache!' do + it 'caches the file in the cache directory' do + # One to get the work dir, the other to remove it + expect(uploader).to receive(:workfile_path).exactly(2).times.and_call_original + expect(FileUtils).to receive(:mv).with(anything, /^#{uploader.work_dir}/).and_call_original + expect(FileUtils).to receive(:mv).with(/^#{uploader.work_dir}/, /^#{uploader.cache_dir}/).and_call_original + + fixture = Rails.root.join('spec', 'fixtures', 'rails_sample.jpg') + uploader.cache!(fixture_file_upload(fixture)) + + expect(uploader.file.path).to start_with(uploader.cache_dir) + end + end + + describe '#move_to_cache' do + it 'is true' do + expect(uploader.move_to_cache).to eq(true) + end + end + + describe '#move_to_store' do + it 'is true' do + expect(uploader.move_to_store).to eq(true) + end + end +end |