summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicaël Bergeron <mbergeron@gitlab.com>2018-06-08 10:51:59 -0400
committerMicaël Bergeron <mbergeron@gitlab.com>2018-06-08 10:51:59 -0400
commite1589a5c584acae83d97d41494616be1f3981da7 (patch)
treee3241222ec597a912e6a7f14a0129af5e5bf3c20
parent50872bcc242a582c7e3af25df4d32e1c3e0a28f3 (diff)
downloadgitlab-ce-e1589a5c584acae83d97d41494616be1f3981da7.tar.gz
apply feedback
-rw-r--r--app/uploaders/object_storage.rb13
-rw-r--r--spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb4
2 files changed, 13 insertions, 4 deletions
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index bebaa3b807b..43c2b419332 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -9,7 +9,16 @@ module ObjectStorage
RemoteStoreError = Class.new(StandardError)
UnknownStoreError = Class.new(StandardError)
ObjectStorageUnavailable = Class.new(StandardError)
- ExclusiveLeaseTaken = Class.new(StandardError)
+
+ class ExclusiveLeaseTaken < StandardError
+ def initialize(lease_key)
+ @lease_key = lease_key
+ end
+
+ def message
+ "Exclusive lease #{@lease_key} already taken."
+ end
+ end
TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
@@ -379,7 +388,7 @@ module ObjectStorage
def with_exclusive_lease
lease_key = exclusive_lease_key
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
- raise ExclusiveLeaseTaken, "Exclusive lease #{lease_key} already taken." unless uuid
+ raise ExclusiveLeaseTaken.new(lease_key) unless uuid
yield uuid
ensure
diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
index ba01cfe53c5..31d323626c5 100644
--- a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
+++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
@@ -129,7 +129,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe "limits N+1 queries" do
let!(:projects) { create_list(:project, 10, :with_avatar) }
- it do
+ it "to N*#{MIGRATION_QUERIES}" do
query_count = ActiveRecord::QueryRecorder.new { perform(uploads) }
more_projects = create_list(:project, 100, :with_avatar)
@@ -158,7 +158,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe "limits N+1 queries" do
let!(:projects) { create_list(:project, 10) }
- it do
+ it "to N*#{MIGRATION_QUERIES}" do
query_count = ActiveRecord::QueryRecorder.new { perform(uploads) }
more_projects = create_list(:project, 100)