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
137541c0
Commit
137541c0
authored
Nov 29, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve comments
parent
af5bf568
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
app/services/ci/archive_trace_service.rb
app/services/ci/archive_trace_service.rb
+12
-2
spec/workers/ci/archive_traces_cron_worker_spec.rb
spec/workers/ci/archive_traces_cron_worker_spec.rb
+15
-0
No files found.
app/services/ci/archive_trace_service.rb
View file @
137541c0
...
...
@@ -7,19 +7,29 @@ module Ci
rescue
::
Gitlab
::
Ci
::
Trace
::
AlreadyArchivedError
# It's already archived, thus we can safely ignore this exception.
rescue
=>
e
# Tracks this error with application logs, Sentry, and Prometheus.
# If `archive!` keeps failing for over a week, that could incur data loss.
# (See more https://docs.gitlab.com/ee/administration/job_traces.html#new-live-trace-architecture)
# In order to avoid interrupting the system, we do not raise an exception here.
archive_error
(
e
,
job
)
end
private
def
failed_archive_counter
@failed_archive_counter
||=
Gitlab
::
Metrics
.
counter
(
:job_trace_archive_failed_total
,
"Counter of failed attempts of trace archiving"
)
@failed_archive_counter
||=
Gitlab
::
Metrics
.
counter
(
:job_trace_archive_failed_total
,
"Counter of failed attempts of trace archiving"
)
end
def
archive_error
(
error
,
job
)
failed_archive_counter
.
increment
Gitlab
::
Sentry
.
track_exception
(
error
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502'
,
extra:
{
job_id:
job
.
id
})
Rails
.
logger
.
error
"Failed to archive trace. id:
#{
job
.
id
}
message:
#{
error
.
message
}
"
Gitlab
::
Sentry
.
track_exception
(
error
,
issue_url:
'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502'
,
extra:
{
job_id:
job
.
id
})
end
end
end
spec/workers/ci/archive_traces_cron_worker_spec.rb
View file @
137541c0
...
...
@@ -48,6 +48,21 @@ describe Ci::ArchiveTracesCronWorker do
expect
(
build2
.
job_artifacts_trace
).
to
be_exist
end
end
context
'when an unexpected exception happened during archiving'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
before
do
allow
(
Gitlab
::
Sentry
).
to
receive
(
:track_exception
)
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:archive!
).
and_raise
(
'Unexpected error'
)
end
it
'puts a log'
do
expect
(
Rails
.
logger
).
to
receive
(
:error
).
with
(
"Failed to archive trace. id:
#{
build
.
id
}
message: Unexpected error"
)
subject
end
end
end
context
'when a job was cancelled'
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