summaryrefslogtreecommitdiff
path: root/app/uploaders
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-06-01 13:15:46 -0700
committerStan Hu <stanhu@gmail.com>2017-06-04 21:51:59 -0700
commit37dd073782520f70d021e8ca9960e0a1c9696129 (patch)
tree6f22e45c5cd7b9d836502a3f4bada0e0e5b325fe /app/uploaders
parent39340e428e3546d3749498ce10b19ae6cda0e646 (diff)
downloadgitlab-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 'app/uploaders')
-rw-r--r--app/uploaders/lfs_object_uploader.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/uploaders/lfs_object_uploader.rb b/app/uploaders/lfs_object_uploader.rb
index 95a891111e1..02589959c2f 100644
--- a/app/uploaders/lfs_object_uploader.rb
+++ b/app/uploaders/lfs_object_uploader.rb
@@ -12,4 +12,20 @@ class LfsObjectUploader < GitlabUploader
def filename
model.oid[4..-1]
end
+
+ def work_dir
+ File.join(Gitlab.config.lfs.storage_path, 'tmp', 'work')
+ end
+
+ private
+
+ # To prevent LFS files from moving across filesystems, override the default
+ # implementation:
+ # http://github.com/carrierwaveuploader/carrierwave/blob/v1.0.0/lib/carrierwave/uploader/cache.rb#L181-L183
+ def workfile_path(for_file = original_filename)
+ # To be safe, keep this directory outside of the the cache directory
+ # because calling CarrierWave.clean_cache_files! will remove any files in
+ # the cache directory.
+ File.join(work_dir, @cache_id, version_name.to_s, for_file)
+ end
end