Commit ded38d5f authored by Shinya Maeda's avatar Shinya Maeda

Add exclusive relase for trace arhive

parent ad12c58f
module Gitlab
module Ci
class Trace
include ExclusiveLeaseGuard
LEASE_TIMEOUT = 1.hour
ArchiveError = Class.new(StandardError)
attr_reader :job
......@@ -108,6 +112,7 @@ module Gitlab
raise ArchiveError, 'Already archived' if trace_artifact
raise ArchiveError, 'Job is not finished yet' unless job.complete?
try_obtain_lease do
if job.trace_chunks.any?
Gitlab::Ci::Trace::ChunkedIO.new(job) do |stream|
archive_stream!(stream)
......@@ -125,6 +130,7 @@ module Gitlab
end
end
end
end
private
......@@ -206,6 +212,16 @@ module Gitlab
def trace_artifact
job.job_artifacts_trace
end
# For ExclusiveLeaseGuard concerns
def lease_key
@lease_key ||= self.class.name.underscore + ":archive:#{job.id}"
end
# For ExclusiveLeaseGuard concern
def lease_timeout
LEASE_TIMEOUT
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