Commit 4d616725 authored by Sean McGivern's avatar Sean McGivern

Merge branch '44774-migrate-upload-task-fails-for-upload-with-store-nil' into 'master'

Resolve "Migrate upload task fails for Upload with `store: nil`"

Closes #44774

See merge request gitlab-org/gitlab-ce!18082
parents 72f2f384 316eb6ef
---
title: Fixed gitlab:uploads:migrate task ignoring some uploads.
merge_request: 18082
author:
type: fixed
...@@ -25,8 +25,8 @@ namespace :gitlab do ...@@ -25,8 +25,8 @@ namespace :gitlab do
Upload.class_eval { include EachBatch } unless Upload < EachBatch Upload.class_eval { include EachBatch } unless Upload < EachBatch
Upload Upload
.where.not(store: @to_store) .where(store: [nil, ObjectStorage::Store::LOCAL],
.where(uploader: @uploader_class.to_s, uploader: @uploader_class.to_s,
model_type: @model_class.base_class.sti_name) model_type: @model_class.base_class.sti_name)
end end
end end
......
...@@ -20,9 +20,23 @@ describe 'gitlab:uploads:migrate rake tasks' do ...@@ -20,9 +20,23 @@ describe 'gitlab:uploads:migrate rake tasks' do
run_rake_task("gitlab:uploads:migrate", *args) run_rake_task("gitlab:uploads:migrate", *args)
end end
it 'enqueue jobs in batch' do shared_examples 'enqueue jobs in batch' do |batch:|
expect(ObjectStorage::MigrateUploadsWorker).to receive(:enqueue!).exactly(4).times it do
expect(ObjectStorage::MigrateUploadsWorker)
.to receive(:perform_async).exactly(batch).times
.and_return("A fake job.")
run run
end
end
it_behaves_like 'enqueue jobs in batch', batch: 4
context 'Upload has store = nil' do
before do
Upload.where(model: projects).update_all(store: nil)
end
it_behaves_like 'enqueue jobs in batch', batch: 4
end end
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