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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
22bdd739
Commit
22bdd739
authored
Oct 12, 2021
by
Sean Arnold
Committed by
Fabio Pitino
Oct 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up failed archive when no more attempts left
Changelog: performance
parent
5e8f3a30
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
8 deletions
+45
-8
app/services/ci/archive_trace_service.rb
app/services/ci/archive_trace_service.rb
+8
-3
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+11
-5
spec/services/ci/archive_trace_service_spec.rb
spec/services/ci/archive_trace_service_spec.rb
+26
-0
No files found.
app/services/ci/archive_trace_service.rb
View file @
22bdd739
...
...
@@ -3,10 +3,15 @@
module
Ci
class
ArchiveTraceService
def
execute
(
job
,
worker_name
:)
unless
job
.
trace
.
archival_attempts_available?
Sidekiq
.
logger
.
warn
(
class:
worker_name
,
message:
'The job is out of archival attempts.'
,
job_id:
job
.
id
)
job
.
trace
.
attempt_archive_cleanup!
return
end
unless
job
.
trace
.
can_attempt_archival_now?
Sidekiq
.
logger
.
warn
(
class:
worker_name
,
message:
job
.
trace
.
archival_attempts_message
,
job_id:
job
.
id
)
Sidekiq
.
logger
.
warn
(
class:
worker_name
,
message:
'The job can not be archived right now.'
,
job_id:
job
.
id
)
return
end
...
...
lib/gitlab/ci/trace.rb
View file @
22bdd739
...
...
@@ -25,7 +25,7 @@ module Gitlab
delegate
:old_trace
,
to: :job
delegate
:can_attempt_archival_now?
,
:increment_archival_attempts!
,
:archival_attempts_message
,
to: :trace_metadata
:archival_attempts_message
,
:archival_attempts_available?
,
to: :trace_metadata
def
initialize
(
job
)
@job
=
job
...
...
@@ -122,6 +122,10 @@ module Gitlab
end
end
def
attempt_archive_cleanup!
destroy_any_orphan_trace_data!
end
def
update_interval
if
being_watched?
UPDATE_FREQUENCY_WHEN_BEING_WATCHED
...
...
@@ -191,7 +195,10 @@ module Gitlab
def
unsafe_archive!
raise
ArchiveError
,
'Job is not finished yet'
unless
job
.
complete?
unsafe_trace_conditionally_cleanup_before_retry!
already_archived?
.
tap
do
|
archived
|
destroy_any_orphan_trace_data!
raise
AlreadyArchivedError
,
'Could not archive again'
if
archived
end
if
job
.
trace_chunks
.
any?
Gitlab
::
Ci
::
Trace
::
ChunkedIO
.
new
(
job
)
do
|
stream
|
...
...
@@ -214,16 +221,15 @@ module Gitlab
def
already_archived?
# TODO check checksum to ensure archive completed successfully
# See https://gitlab.com/gitlab-org/gitlab/-/issues/259619
trace_artifact
.
archived_trace_exists?
trace_artifact
&
.
archived_trace_exists?
end
def
unsafe_trace_conditionally_cleanup_before_retry
!
def
destroy_any_orphan_trace_data
!
return
unless
trace_artifact
if
already_archived?
# An archive already exists, so make sure to remove the trace chunks
erase_trace_chunks!
raise
AlreadyArchivedError
,
'Could not archive again'
else
# An archive already exists, but its associated file does not, so remove it
trace_artifact
.
destroy!
...
...
spec/services/ci/archive_trace_service_spec.rb
View file @
22bdd739
...
...
@@ -88,6 +88,32 @@ RSpec.describe Ci::ArchiveTraceService, '#execute' do
subject
end
context
'job has archive and chunks'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
)
}
before
do
create
(
:ci_build_trace_chunk
,
build:
job
,
chunk_index:
0
)
end
context
'archive is not completed'
do
before
do
job
.
job_artifacts_trace
.
file
.
remove!
end
it
'cleanups any stale archive data'
do
expect
(
job
.
job_artifacts_trace
).
to
be_present
subject
expect
(
job
.
reload
.
job_artifacts_trace
).
to
be_nil
end
end
it
'removes trace chunks'
do
expect
{
subject
}.
to
change
{
job
.
trace_chunks
.
count
}.
to
(
0
)
end
end
end
context
'when the archival process is backed off'
do
...
...
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