Commit 47475322 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add a custom exception used with build trace locking

parent e7f22619
......@@ -16,6 +16,7 @@ module Gitlab
ArchiveError = Class.new(StandardError)
AlreadyArchivedError = Class.new(StandardError)
LockedError = Class.new(StandardError)
attr_reader :job
......@@ -132,6 +133,8 @@ module Gitlab
def lock(&block)
in_write_lock(&block)
rescue FailedToObtainLockError
raise LockedError, "build trace `#{job.id}` is locked"
end
private
......
......@@ -116,7 +116,7 @@ RSpec.describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state do
it 'acquires an exclusive lease on the trace' do
trace.lock do
expect { trace.lock }
.to raise_error ::Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
.to raise_error described_class::LockedError
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