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
d7e6a633
Commit
d7e6a633
authored
Jun 06, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only update Prom apps specific to environment
parent
9783ae9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
app/services/prometheus/create_default_alerts_service.rb
app/services/prometheus/create_default_alerts_service.rb
+5
-1
spec/services/prometheus/create_default_alerts_service_spec.rb
...services/prometheus/create_default_alerts_service_spec.rb
+15
-10
No files found.
app/services/prometheus/create_default_alerts_service.rb
View file @
d7e6a633
...
...
@@ -53,7 +53,11 @@ module Prometheus
end
def
schedule_prometheus_update
project
.
all_clusters
.
with_application_prometheus
.
each
do
|
cluster
|
clusters
=
project
.
all_clusters
clusters
=
clusters
.
with_application_prometheus
clusters
=
clusters
.
with_deployment_in_environment
(
environment
)
clusters
.
each
do
|
cluster
|
application
=
cluster
.
application_prometheus
::
Clusters
::
Applications
::
ScheduleUpdateService
.
new
(
application
,
project
).
execute
end
...
...
spec/services/prometheus/create_default_alerts_service_spec.rb
View file @
d7e6a633
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
describe
Prometheus
::
CreateDefaultAlertsService
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:instance
)
{
described_class
.
new
(
project:
project
)
}
let
(
:expected_alerts
)
{
described_class
::
DEFAULT_ALERTS
}
...
...
@@ -51,12 +51,16 @@ describe Prometheus::CreateDefaultAlertsService do
end
context
'cluster with prometheus exists'
do
let!
(
:cluster
)
do
cluster
=
create
(
:cluster
,
:with_installed_prometheus
)
cluster
.
projects
<<
project
cluster
let!
(
:cluster
)
{
create
(
:cluster
,
:with_installed_prometheus
,
projects:
[
project
])
}
it
'does not schedule an update to prometheus'
do
expect
(
::
Clusters
::
Applications
::
ScheduleUpdateService
).
not_to
receive
(
:new
)
execute
end
context
'deployment to relevant environment'
do
let!
(
:deployment
)
{
create
(
:deployment
,
cluster:
cluster
,
environment:
environment
,
sha:
project
.
commit
.
id
)
}
it
'schedules an update to prometheus'
do
expect_next_instance_of
(
::
Clusters
::
Applications
::
ScheduleUpdateService
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:execute
)
...
...
@@ -65,6 +69,7 @@ describe Prometheus::CreateDefaultAlertsService do
execute
end
end
end
context
'multiple environments'
do
let!
(
:production
)
{
create
(
:environment
,
project:
project
,
name:
'production'
)
}
...
...
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