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
8cc3dc10
Commit
8cc3dc10
authored
Jun 09, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Access prometheus via cluster_prometheus_adapter
- Update specs - Delete unnecessary code
parent
d7e6a633
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
41 deletions
+12
-41
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+0
-1
app/services/prometheus/create_default_alerts_service.rb
app/services/prometheus/create_default_alerts_service.rb
+6
-7
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+0
-18
spec/services/prometheus/create_default_alerts_service_spec.rb
...services/prometheus/create_default_alerts_service_spec.rb
+6
-15
No files found.
app/models/clusters/cluster.rb
View file @
8cc3dc10
...
...
@@ -136,7 +136,6 @@ module Clusters
conditions
=
{
projects:
{
alerts_service:
[
:data
]
}
}
includes
(
conditions
).
joins
(
conditions
).
where
(
projects:
{
id:
project_ids
})
end
scope
:with_deployment_in_environment
,
->
(
environment
)
{
joins
(
:deployments
).
merge
(
Deployment
.
for_environment
(
environment
))
}
def
self
.
ancestor_clusters_for_clusterable
(
clusterable
,
hierarchy_order: :asc
)
return
[]
if
clusterable
.
is_a?
(
Instance
)
...
...
app/services/prometheus/create_default_alerts_service.rb
View file @
8cc3dc10
...
...
@@ -53,14 +53,13 @@ module Prometheus
end
def
schedule_prometheus_update
clusters
=
project
.
all_clusters
clusters
=
clusters
.
with_application_prometheus
clusters
=
clusters
.
with_deployment_in_environment
(
environment
)
return
unless
prometheus_application
clusters
.
each
do
|
cluster
|
application
=
cluster
.
application_prometheus
::
Clusters
::
Applications
::
ScheduleUpdateService
.
new
(
application
,
project
).
execute
end
::
Clusters
::
Applications
::
ScheduleUpdateService
.
new
(
prometheus_application
,
project
).
execute
end
def
prometheus_application
environment
.
cluster_prometheus_adapter
end
def
metrics_by_identifier
...
...
spec/models/clusters/cluster_spec.rb
View file @
8cc3dc10
...
...
@@ -207,24 +207,6 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
end
describe
'.with_project_alert_service_data'
do
subject
{
described_class
.
with_deployment_in_environment
(
environment
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
projects:
[
project
])
}
let!
(
:environment
)
{
create
(
:environment
)
}
context
'deployment in environment'
do
let!
(
:deployment
)
{
create
(
:deployment
,
cluster:
cluster
,
environment:
environment
,
sha:
cluster
.
project
.
commit
.
id
)
}
it
{
is_expected
.
to
include
(
cluster
)
}
end
context
'no deployment in environment'
do
it
{
is_expected
.
not_to
include
(
cluster
)
}
end
end
describe
'.for_project_namespace'
do
subject
{
described_class
.
for_project_namespace
(
namespace_id
)
}
...
...
spec/services/prometheus/create_default_alerts_service_spec.rb
View file @
8cc3dc10
...
...
@@ -51,23 +51,14 @@ describe Prometheus::CreateDefaultAlertsService do
end
context
'cluster with prometheus exists'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:with_installed_prometheus
,
projects:
[
project
])
}
let!
(
:cluster
)
{
create
(
:cluster
,
:with_installed_prometheus
,
:provided_by_user
,
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
)
end
execute
it
'schedules an update to prometheus'
do
expect_next_instance_of
(
::
Clusters
::
Applications
::
ScheduleUpdateService
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:execute
)
end
execute
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