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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
57c1f7ca
Commit
57c1f7ca
authored
Jan 04, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop warnings
parent
09473b19
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
13 deletions
+19
-13
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+6
-3
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
+1
-1
spec/models/clusters/applications/prometheus_spec.rb
spec/models/clusters/applications/prometheus_spec.rb
+10
-7
spec/models/project_services/prometheus_service_spec.rb
spec/models/project_services/prometheus_service_spec.rb
+2
-2
No files found.
app/models/project_services/prometheus_service.rb
View file @
57c1f7ca
...
@@ -23,7 +23,7 @@ class PrometheusService < MonitoringService
...
@@ -23,7 +23,7 @@ class PrometheusService < MonitoringService
def
initialize_properties
def
initialize_properties
if
properties
.
nil?
if
properties
.
nil?
self
.
properties
=
{
}
self
.
properties
=
{}
end
end
end
end
...
@@ -45,7 +45,8 @@ class PrometheusService < MonitoringService
...
@@ -45,7 +45,8 @@ class PrometheusService < MonitoringService
def
fields
def
fields
[
[
{
type:
'fieldset'
,
{
type:
'fieldset'
,
legend:
'Manual Configuration'
,
legend:
'Manual Configuration'
,
fields:
[
fields:
[
{
{
...
@@ -100,6 +101,7 @@ class PrometheusService < MonitoringService
...
@@ -100,6 +101,7 @@ class PrometheusService < MonitoringService
# Cache metrics for specific environment
# Cache metrics for specific environment
def
calculate_reactive_cache
(
query_class_name
,
environment_id
,
*
args
)
def
calculate_reactive_cache
(
query_class_name
,
environment_id
,
*
args
)
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
client
=
client
(
environment_id
)
client
=
client
(
environment_id
)
data
=
Kernel
.
const_get
(
query_class_name
).
new
(
client
).
query
(
environment_id
,
*
args
)
data
=
Kernel
.
const_get
(
query_class_name
).
new
(
client
).
query
(
environment_id
,
*
args
)
...
@@ -118,9 +120,10 @@ class PrometheusService < MonitoringService
...
@@ -118,9 +120,10 @@ class PrometheusService < MonitoringService
else
else
cluster
=
cluster_with_prometheus
(
environment_id
)
cluster
=
cluster_with_prometheus
(
environment_id
)
raise
Gitlab
::
PrometheusError
,
"couldn't find cluster with Prometheus installed"
unless
cluster
raise
Gitlab
::
PrometheusError
,
"couldn't find cluster with Prometheus installed"
unless
cluster
rest_client
=
client_from_cluster
(
cluster
)
rest_client
=
client_from_cluster
(
cluster
)
raise
Gitlab
::
PrometheusError
,
"couldn't create proxy Prometheus client"
unless
rest_client
raise
Gitlab
::
PrometheusError
,
"couldn't create proxy Prometheus client"
unless
rest_client
Gitlab
::
PrometheusClient
.
new
(
rest_client
)
Gitlab
::
PrometheusClient
.
new
(
rest_client
)
end
end
end
end
...
...
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
View file @
57c1f7ca
spec/models/clusters/applications/prometheus_spec.rb
View file @
57c1f7ca
...
@@ -51,13 +51,16 @@ describe Clusters::Applications::Prometheus do
...
@@ -51,13 +51,16 @@ describe Clusters::Applications::Prometheus do
context
'cluster has kubeclient'
do
context
'cluster has kubeclient'
do
let
(
:kubernetes_url
)
{
'http://example.com'
}
let
(
:kubernetes_url
)
{
'http://example.com'
}
let
(
:k8s_discover_response
)
{
{
let
(
:k8s_discover_response
)
do
{
resources:
[
resources:
[
{
{
name:
'service'
,
name:
'service'
,
kind:
'Service'
kind:
'Service'
}]
}
}
}
]
}
end
let
(
:kube_client
)
{
Kubeclient
::
Client
.
new
(
kubernetes_url
)
}
let
(
:kube_client
)
{
Kubeclient
::
Client
.
new
(
kubernetes_url
)
}
...
...
spec/models/project_services/prometheus_service_spec.rb
View file @
57c1f7ca
...
@@ -205,7 +205,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
...
@@ -205,7 +205,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
context
'with cluster for all environments without prometheus installed'
do
context
'with cluster for all environments without prometheus installed'
do
context
'without environment supplied'
do
context
'without environment supplied'
do
it
'raises PrometheusError because cluster was not found'
do
it
'raises PrometheusError because cluster was not found'
do
expect
{
service
.
client
}.
to
raise_error
(
Gitlab
::
PrometheusError
,
/couldn't find cluster with Prometheus installed/
)
expect
{
service
.
client
}.
to
raise_error
(
Gitlab
::
PrometheusError
,
/couldn't find cluster with Prometheus installed/
)
end
end
end
end
...
@@ -224,7 +224,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
...
@@ -224,7 +224,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
let!
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'prod'
)
}
let!
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'prod'
)
}
it
'raises PrometheusError because cluster was not found'
do
it
'raises PrometheusError because cluster was not found'
do
expect
{
service
.
client
}.
to
raise_error
(
Gitlab
::
PrometheusError
,
/couldn't find cluster with Prometheus installed/
)
expect
{
service
.
client
}.
to
raise_error
(
Gitlab
::
PrometheusError
,
/couldn't find cluster with Prometheus installed/
)
end
end
end
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