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
687343bf
Commit
687343bf
authored
Nov 15, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check Prometheus Alert payload size only once
parent
176e9b87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
ee/app/services/projects/prometheus/alerts/notify_service.rb
ee/app/services/projects/prometheus/alerts/notify_service.rb
+6
-11
No files found.
ee/app/services/projects/prometheus/alerts/notify_service.rb
View file @
687343bf
...
...
@@ -4,11 +4,10 @@ module Projects
module
Prometheus
module
Alerts
class
NotifyService
<
BaseService
BadPayloadError
=
Class
.
new
(
StandardError
)
include
Gitlab
::
Utils
::
StrongMemoize
def
execute
(
token
)
return
false
unless
valid_payload_size?
return
false
unless
valid_version?
return
false
unless
valid_alert_manager_token?
(
token
)
...
...
@@ -17,16 +16,12 @@ module Projects
process_incident_issues
if
process_issues?
true
rescue
BadPayloadError
false
end
private
def
payload
raise
BadPayloadError
,
'The payload is too big'
unless
Gitlab
::
Utils
::
DeepSize
.
new
(
params
).
valid?
params
def
valid_payload_size?
Gitlab
::
Utils
::
DeepSize
.
new
(
params
).
valid?
end
def
incident_management_available?
...
...
@@ -66,11 +61,11 @@ module Projects
end
def
alerts
pa
yload
[
'alerts'
]
pa
rams
[
'alerts'
]
end
def
valid_version?
pa
yload
[
'version'
]
==
'4'
pa
rams
[
'version'
]
==
'4'
end
def
valid_alert_manager_token?
(
token
)
...
...
@@ -144,7 +139,7 @@ module Projects
end
def
persist_events
CreateEventsService
.
new
(
project
,
nil
,
pa
yload
).
execute
CreateEventsService
.
new
(
project
,
nil
,
pa
rams
).
execute
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