Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-02 07:08:34 +0300
committerShinya Maeda <shinya@gitlab.com>2018-06-06 11:49:48 +0300
commit5a1ee0c391a06a323d960eab6ffb33dfcf2edca7 (patch)
tree0112d50f35408d4c04c4c6e8b4e473989a08eb97 /lib
parent2084e7ab9aad92d4a8196af01b9b8e02ffacb0a4 (diff)
Fix the query to select stale live traces
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/trace.rb42
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb
index 5feef77e27e..a52d71225bb 100644
--- a/lib/gitlab/ci/trace.rb
+++ b/lib/gitlab/ci/trace.rb
@@ -109,31 +109,35 @@ module Gitlab
end
def archive!
+ try_obtain_lease do
+ unsafe_archive!
+ end
+ end
+
+ private
+
+ def unsafe_archive!
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)
- stream.destroy!
- end
- elsif current_path
- File.open(current_path) do |stream|
- archive_stream!(stream)
- FileUtils.rm(current_path)
- end
- elsif old_trace
- StringIO.new(old_trace, 'rb').tap do |stream|
- archive_stream!(stream)
- job.erase_old_trace!
- end
+ if job.trace_chunks.any?
+ Gitlab::Ci::Trace::ChunkedIO.new(job) do |stream|
+ archive_stream!(stream)
+ stream.destroy!
+ end
+ elsif current_path
+ File.open(current_path) do |stream|
+ archive_stream!(stream)
+ FileUtils.rm(current_path)
+ end
+ elsif old_trace
+ StringIO.new(old_trace, 'rb').tap do |stream|
+ archive_stream!(stream)
+ job.erase_old_trace!
end
end
end
- private
-
def archive_stream!(stream)
clone_file!(stream, JobArtifactUploader.workhorse_upload_path) do |clone_path|
create_build_trace!(job, clone_path)
@@ -213,7 +217,7 @@ module Gitlab
job.job_artifacts_trace
end
- # For ExclusiveLeaseGuard concerns
+ # For ExclusiveLeaseGuard concern
def lease_key
@lease_key ||= "trace:archive:#{job.id}"
end