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
140f2a93
Commit
140f2a93
authored
Dec 14, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make NetworkAlertService a user-less service
parent
cc0bc406
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
5 deletions
+12
-5
ee/app/services/alert_management/network_alert_service.rb
ee/app/services/alert_management/network_alert_service.rb
+10
-3
ee/lib/ee/api/internal/kubernetes.rb
ee/lib/ee/api/internal/kubernetes.rb
+1
-1
ee/spec/services/alert_management/network_alert_service_spec.rb
...c/services/alert_management/network_alert_service_spec.rb
+1
-1
No files found.
ee/app/services/alert_management/network_alert_service.rb
View file @
140f2a93
...
...
@@ -2,12 +2,17 @@
module
AlertManagement
# Create alerts coming K8 through gitlab-agent
class
NetworkAlertService
<
BaseService
class
NetworkAlertService
include
Gitlab
::
Utils
::
StrongMemoize
include
::
IncidentManagement
::
Settings
MONITORING_TOOL
=
Gitlab
::
AlertManagement
::
Payload
::
MONITORING_TOOLS
.
fetch
(
:cilium
)
def
initialize
(
project
,
payload
)
@project
=
project
@payload
=
payload
end
# Users of this service need to check the agent token before calling `execute`.
# https://gitlab.com/gitlab-org/gitlab/-/issues/292707 will handle token within the service.
def
execute
...
...
@@ -24,8 +29,10 @@ module AlertManagement
private
attr_reader
:project
,
:payload
def
valid_payload_size?
Gitlab
::
Utils
::
DeepSize
.
new
(
pa
rams
).
valid?
Gitlab
::
Utils
::
DeepSize
.
new
(
pa
yload
).
valid?
end
def
process_request
...
...
@@ -78,7 +85,7 @@ module AlertManagement
strong_memoize
(
:incoming_payload
)
do
Gitlab
::
AlertManagement
::
Payload
.
parse
(
project
,
pa
rams
,
pa
yload
,
monitoring_tool:
MONITORING_TOOL
)
end
...
...
ee/lib/ee/api/internal/kubernetes.rb
View file @
140f2a93
...
...
@@ -25,7 +25,7 @@ module EE
forbidden!
unless
project
.
feature_available?
(
:cilium_alerts
)
result
=
::
AlertManagement
::
NetworkAlertService
.
new
(
agent
.
project
,
nil
,
params
[
:alert
]).
execute
result
=
::
AlertManagement
::
NetworkAlertService
.
new
(
agent
.
project
,
params
[
:alert
]).
execute
status
result
.
http_status
end
...
...
ee/spec/services/alert_management/network_alert_service_spec.rb
View file @
140f2a93
...
...
@@ -7,7 +7,7 @@ RSpec.describe AlertManagement::NetworkAlertService do
let_it_be
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
describe
'#execute'
do
let
(
:service
)
{
described_class
.
new
(
project
,
nil
,
payload
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
payload
)
}
let
(
:tool
)
{
Gitlab
::
AlertManagement
::
Payload
::
MONITORING_TOOLS
[
:cilium
]
}
let
(
:starts_at
)
{
Time
.
current
.
change
(
usec:
0
)
}
let
(
:ended_at
)
{
nil
}
...
...
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