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
ba7cfdc2
Commit
ba7cfdc2
authored
Nov 14, 2018
by
Dylan Griffith
Committed by
Kamil Trzciński
Nov 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track Kubernetes errors using Sentry
parent
dff3ded5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
app/services/clusters/applications/check_installation_progress_service.rb
...sters/applications/check_installation_progress_service.rb
+1
-0
app/services/clusters/applications/install_service.rb
app/services/clusters/applications/install_service.rb
+2
-0
lib/gitlab/sentry.rb
lib/gitlab/sentry.rb
+11
-3
spec/lib/gitlab/sentry_spec.rb
spec/lib/gitlab/sentry_spec.rb
+24
-0
No files found.
app/services/clusters/applications/check_installation_progress_service.rb
View file @
ba7cfdc2
...
...
@@ -16,6 +16,7 @@ module Clusters
end
rescue
Kubeclient
::
HttpError
=>
e
Rails
.
logger
.
error
(
"Kubernetes error:
#{
e
.
error_code
}
#{
e
.
message
}
"
)
Gitlab
::
Sentry
.
track_acceptable_exception
(
e
,
extra:
{
scope:
'kubernetes'
,
app_id:
app
.
id
})
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
unless
app
.
errored?
end
...
...
app/services/clusters/applications/install_service.rb
View file @
ba7cfdc2
...
...
@@ -14,9 +14,11 @@ module Clusters
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
rescue
Kubeclient
::
HttpError
=>
e
Rails
.
logger
.
error
(
"Kubernetes error:
#{
e
.
error_code
}
#{
e
.
message
}
"
)
Gitlab
::
Sentry
.
track_acceptable_exception
(
e
,
extra:
{
scope:
'kubernetes'
,
app_id:
app
.
id
})
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
rescue
StandardError
=>
e
Rails
.
logger
.
error
"Can't start installation process:
#{
e
.
class
.
name
}
#{
e
.
message
}
"
Gitlab
::
Sentry
.
track_acceptable_exception
(
e
,
extra:
{
scope:
'kubernetes'
,
app_id:
app
.
id
})
app
.
make_errored!
(
"Can't start installation process."
)
end
end
...
...
lib/gitlab/sentry.rb
View file @
ba7cfdc2
...
...
@@ -7,7 +7,7 @@ module Gitlab
end
def
self
.
context
(
current_user
=
nil
)
return
unless
self
.
enabled?
return
unless
enabled?
Raven
.
tags_context
(
locale:
I18n
.
locale
)
...
...
@@ -29,14 +29,22 @@ module Gitlab
#
# Provide an issue URL for follow up.
def
self
.
track_exception
(
exception
,
issue_url:
nil
,
extra:
{})
track_acceptable_exception
(
exception
,
issue_url:
issue_url
,
extra:
extra
)
raise
exception
if
should_raise?
end
# This should be used when you do not want to raise an exception in
# development and test. If you need development and test to behave
# just the same as production you can use this instead of
# track_exception.
def
self
.
track_acceptable_exception
(
exception
,
issue_url:
nil
,
extra:
{})
if
enabled?
extra
[
:issue_url
]
=
issue_url
if
issue_url
context
# Make sure we've set everything we know in the context
Raven
.
capture_exception
(
exception
,
extra:
extra
)
end
raise
exception
if
should_raise?
end
def
self
.
program_context
...
...
spec/lib/gitlab/sentry_spec.rb
View file @
ba7cfdc2
...
...
@@ -52,4 +52,28 @@ describe Gitlab::Sentry do
end
end
end
context
'.track_acceptable_exception'
do
let
(
:exception
)
{
RuntimeError
.
new
(
'boom'
)
}
before
do
allow
(
described_class
).
to
receive
(
:enabled?
).
and_return
(
true
)
end
it
'calls Raven.capture_exception'
do
expected_extras
=
{
some_other_info:
'info'
,
issue_url:
'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
}
expect
(
Raven
).
to
receive
(
:capture_exception
)
.
with
(
exception
,
extra:
a_hash_including
(
expected_extras
))
described_class
.
track_acceptable_exception
(
exception
,
issue_url:
'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
,
extra:
{
some_other_info:
'info'
}
)
end
end
end
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