Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
04ab732f
Commit
04ab732f
authored
Jul 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove traces efficiently
parent
4c1a2a9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
app/models/ci/build.rb
app/models/ci/build.rb
+6
-0
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+13
-8
No files found.
app/models/ci/build.rb
View file @
04ab732f
...
...
@@ -376,6 +376,10 @@ module Ci
trace
.
exist?
end
def
has_old_trace?
old_trace
.
present?
end
def
trace
=
(
data
)
raise
NotImplementedError
end
...
...
@@ -385,6 +389,8 @@ module Ci
end
def
erase_old_trace!
raise
Gitlab
::
Ci
::
Trace
::
EraseError
,
'Old trace does not exist'
unless
has_old_trace?
update_column
(
:trace
,
nil
)
end
...
...
lib/gitlab/ci/trace.rb
View file @
04ab732f
...
...
@@ -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!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment