summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/trace.rb
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-07-03 14:00:25 +0900
committerShinya Maeda <shinya@gitlab.com>2018-07-04 14:30:55 +0900
commit04ab732f30c689d87dee0e1b8c5832a0b6824269 (patch)
tree9e43baf74674e661a13115555e77eafd62358535 /lib/gitlab/ci/trace.rb
parent4c1a2a9b9977f68a05512ed1ff378ee0a2368aca (diff)
downloadgitlab-ce-04ab732f30c689d87dee0e1b8c5832a0b6824269.tar.gz
Remove traces efficiently
Diffstat (limited to 'lib/gitlab/ci/trace.rb')
-rw-r--r--lib/gitlab/ci/trace.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb
index a52d71225bb..ddf78b0b893 100644
--- a/lib/gitlab/ci/trace.rb
+++ b/lib/gitlab/ci/trace.rb
@@ -6,6 +6,7 @@ module Gitlab
LEASE_TIMEOUT = 1.hour
ArchiveError = Class.new(StandardError)
+ EraseError = Class.new(StandardError)
attr_reader :job
@@ -98,14 +99,18 @@ module Gitlab
end
def erase!
- trace_artifact&.destroy
-
- paths.each do |trace_path|
- FileUtils.rm(trace_path, force: true)
- end
-
- job.trace_chunks.fast_destroy_all
- job.erase_old_trace!
+ ##
+ # Erase an archived traces
+ # This removes both a database-row and a real file in either a file storage or a object storage
+ trace_artifact&.destroy!
+
+ ##
+ # Erase a live trace
+ # Basically, jobs have _one_ of the following live traces, but it might be able to happen by a race condition
+ # Therefore, we remove all type of live traces.
+ job.trace_chunks.fast_destroy_all # Destroy chunks of a live trace
+ FileUtils.rm_f(current_path) if current_path # Remove a trace file of a live trace
+ job.erase_old_trace! if job.has_old_trace? # Remove a trace in database of a live trace
end
def archive!