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
46a2adf8
Commit
46a2adf8
authored
Dec 04, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use HttpIntegrations to monitor demo projects for monitor team
parent
1588893c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
12 deletions
+14
-12
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+2
-2
app/services/clusters/applications/prometheus_health_check_service.rb
.../clusters/applications/prometheus_health_check_service.rb
+4
-2
app/workers/clusters/applications/check_prometheus_health_worker.rb
...s/clusters/applications/check_prometheus_health_worker.rb
+1
-1
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+3
-3
spec/services/clusters/applications/prometheus_health_check_service_spec.rb
...ters/applications/prometheus_health_check_service_spec.rb
+3
-3
spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb
...sters/applications/check_prometheus_health_worker_spec.rb
+1
-1
No files found.
app/models/clusters/cluster.rb
View file @
46a2adf8
...
@@ -149,8 +149,8 @@ module Clusters
...
@@ -149,8 +149,8 @@ module Clusters
scope
:for_project_namespace
,
->
(
namespace_id
)
{
joins
(
:projects
).
where
(
projects:
{
namespace_id:
namespace_id
})
}
scope
:for_project_namespace
,
->
(
namespace_id
)
{
joins
(
:projects
).
where
(
projects:
{
namespace_id:
namespace_id
})
}
scope
:with_application_prometheus
,
->
{
includes
(
:application_prometheus
).
joins
(
:application_prometheus
)
}
scope
:with_application_prometheus
,
->
{
includes
(
:application_prometheus
).
joins
(
:application_prometheus
)
}
scope
:with_project_
alert_service_data
,
->
(
project_ids
)
do
scope
:with_project_
http_integrations
,
->
(
project_ids
)
do
conditions
=
{
projects:
{
alerts_service:
[
:data
]
}
}
conditions
=
{
projects:
:alert_management_http_integrations
}
includes
(
conditions
).
joins
(
conditions
).
where
(
projects:
{
id:
project_ids
})
includes
(
conditions
).
joins
(
conditions
).
where
(
projects:
{
id:
project_ids
})
end
end
...
...
app/services/clusters/applications/prometheus_health_check_service.rb
View file @
46a2adf8
...
@@ -63,8 +63,10 @@ module Clusters
...
@@ -63,8 +63,10 @@ module Clusters
def
send_notification
(
project
)
def
send_notification
(
project
)
notification_payload
=
build_notification_payload
(
project
)
notification_payload
=
build_notification_payload
(
project
)
token
=
project
.
alerts_service
.
data
.
token
integration
=
project
.
alert_management_http_integrations
.
active
.
first
Projects
::
Alerting
::
NotifyService
.
new
(
project
,
nil
,
notification_payload
).
execute
(
token
)
Projects
::
Alerting
::
NotifyService
.
new
(
project
,
nil
,
notification_payload
).
execute
(
integration
&
.
token
,
integration
)
@logger
.
info
(
message:
'Successfully notified of Prometheus newly unhealthy'
,
cluster_id:
@cluster
.
id
,
project_id:
project
.
id
)
@logger
.
info
(
message:
'Successfully notified of Prometheus newly unhealthy'
,
cluster_id:
@cluster
.
id
,
project_id:
project
.
id
)
end
end
...
...
app/workers/clusters/applications/check_prometheus_health_worker.rb
View file @
46a2adf8
...
@@ -20,7 +20,7 @@ module Clusters
...
@@ -20,7 +20,7 @@ module Clusters
demo_project_ids
=
Gitlab
::
Monitor
::
DemoProjects
.
primary_keys
demo_project_ids
=
Gitlab
::
Monitor
::
DemoProjects
.
primary_keys
clusters
=
Clusters
::
Cluster
.
with_application_prometheus
clusters
=
Clusters
::
Cluster
.
with_application_prometheus
.
with_project_
alert_service_data
(
demo_project_ids
)
.
with_project_
http_integrations
(
demo_project_ids
)
# Move to a seperate worker with scoped context if expanded to do work on customer projects
# Move to a seperate worker with scoped context if expanded to do work on customer projects
clusters
.
each
{
|
cluster
|
Clusters
::
Applications
::
PrometheusHealthCheckService
.
new
(
cluster
).
execute
}
clusters
.
each
{
|
cluster
|
Clusters
::
Applications
::
PrometheusHealthCheckService
.
new
(
cluster
).
execute
}
...
...
spec/models/clusters/cluster_spec.rb
View file @
46a2adf8
...
@@ -262,14 +262,14 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
...
@@ -262,14 +262,14 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
end
end
end
describe
'.with_project_
alert_service_data
'
do
describe
'.with_project_
http_integrations
'
do
subject
{
described_class
.
with_project_
alert_service_data
(
project_id
)
}
subject
{
described_class
.
with_project_
http_integrations
(
project_id
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
)
}
let!
(
:cluster
)
{
create
(
:cluster
,
:project
)
}
let!
(
:project_id
)
{
cluster
.
first_project
.
id
}
let!
(
:project_id
)
{
cluster
.
first_project
.
id
}
context
'project has alert service data'
do
context
'project has alert service data'
do
let!
(
:
alerts_service
)
{
create
(
:alerts_service
,
project:
cluster
.
clusterable
)
}
let!
(
:
integration
)
{
create
(
:alert_management_http_integration
,
project:
cluster
.
clusterable
)
}
it
{
is_expected
.
to
include
(
cluster
)
}
it
{
is_expected
.
to
include
(
cluster
)
}
end
end
...
...
spec/services/clusters/applications/prometheus_health_check_service_spec.rb
View file @
46a2adf8
...
@@ -18,7 +18,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute'
...
@@ -18,7 +18,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute'
RSpec
.
shared_examples
'sends alert'
do
RSpec
.
shared_examples
'sends alert'
do
it
'sends an alert'
do
it
'sends an alert'
do
expect_next_instance_of
(
Projects
::
Alerting
::
NotifyService
)
do
|
notify_service
|
expect_next_instance_of
(
Projects
::
Alerting
::
NotifyService
)
do
|
notify_service
|
expect
(
notify_service
).
to
receive
(
:execute
).
with
(
alerts_service
.
toke
n
)
expect
(
notify_service
).
to
receive
(
:execute
).
with
(
integration
.
token
,
integratio
n
)
end
end
subject
subject
...
@@ -40,8 +40,8 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute'
...
@@ -40,8 +40,8 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute'
end
end
context
'when cluster is project_type'
do
context
'when cluster is project_type'
do
let_it_be
(
:
alerts_service
)
{
create
(
:alerts_service
)
}
let_it_be
(
:
project
)
{
create
(
:project
)
}
let_it_be
(
:
project
)
{
create
(
:project
,
alerts_service:
alerts_service
)
}
let_it_be
(
:
integration
)
{
create
(
:alert_management_http_integration
,
project:
project
)
}
let
(
:applications_prometheus_healthy
)
{
true
}
let
(
:applications_prometheus_healthy
)
{
true
}
let
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
status:
prometheus_status_value
,
healthy:
applications_prometheus_healthy
)
}
let
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
status:
prometheus_status_value
,
healthy:
applications_prometheus_healthy
)
}
let
(
:cluster
)
{
create
(
:cluster
,
:project
,
application_prometheus:
prometheus
,
projects:
[
project
])
}
let
(
:cluster
)
{
create
(
:cluster
,
:project
,
application_prometheus:
prometheus
,
projects:
[
project
])
}
...
...
spec/workers/clusters/applications/check_prometheus_health_worker_spec.rb
View file @
46a2adf8
...
@@ -8,7 +8,7 @@ RSpec.describe Clusters::Applications::CheckPrometheusHealthWorker, '#perform' d
...
@@ -8,7 +8,7 @@ RSpec.describe Clusters::Applications::CheckPrometheusHealthWorker, '#perform' d
it
'triggers health service'
do
it
'triggers health service'
do
cluster
=
create
(
:cluster
)
cluster
=
create
(
:cluster
)
allow
(
Gitlab
::
Monitor
::
DemoProjects
).
to
receive
(
:primary_keys
)
allow
(
Gitlab
::
Monitor
::
DemoProjects
).
to
receive
(
:primary_keys
)
allow
(
Clusters
::
Cluster
).
to
receive_message_chain
(
:with_application_prometheus
,
:with_project_
alert_service_data
).
and_return
([
cluster
])
allow
(
Clusters
::
Cluster
).
to
receive_message_chain
(
:with_application_prometheus
,
:with_project_
http_integrations
).
and_return
([
cluster
])
service_instance
=
instance_double
(
Clusters
::
Applications
::
PrometheusHealthCheckService
)
service_instance
=
instance_double
(
Clusters
::
Applications
::
PrometheusHealthCheckService
)
expect
(
Clusters
::
Applications
::
PrometheusHealthCheckService
).
to
receive
(
:new
).
with
(
cluster
).
and_return
(
service_instance
)
expect
(
Clusters
::
Applications
::
PrometheusHealthCheckService
).
to
receive
(
:new
).
with
(
cluster
).
and_return
(
service_instance
)
...
...
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