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
Boxiang Sun
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
Hide 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
def
initialize_properties
if
properties
.
nil?
self
.
properties
=
{
}
self
.
properties
=
{}
end
end
...
...
@@ -45,7 +45,8 @@ class PrometheusService < MonitoringService
def
fields
[
{
type:
'fieldset'
,
{
type:
'fieldset'
,
legend:
'Manual Configuration'
,
fields:
[
{
...
...
@@ -100,6 +101,7 @@ class PrometheusService < MonitoringService
# Cache metrics for specific environment
def
calculate_reactive_cache
(
query_class_name
,
environment_id
,
*
args
)
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
client
=
client
(
environment_id
)
data
=
Kernel
.
const_get
(
query_class_name
).
new
(
client
).
query
(
environment_id
,
*
args
)
...
...
@@ -118,9 +120,10 @@ class PrometheusService < MonitoringService
else
cluster
=
cluster_with_prometheus
(
environment_id
)
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
Gitlab
::
PrometheusClient
.
new
(
rest_client
)
end
end
...
...
spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
View file @
57c1f7ca
...
...
@@ -32,6 +32,6 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do
time:
stop_time
)
expect
(
subject
.
query
(
environment
.
id
,
deployment
.
id
)).
to
eq
(
memory_values:
nil
,
memory_before:
nil
,
memory_after:
nil
,
cpu_values:
nil
,
cpu_before:
nil
,
cpu_after:
nil
)
cpu_values:
nil
,
cpu_before:
nil
,
cpu_after:
nil
)
end
end
spec/models/clusters/applications/prometheus_spec.rb
View file @
57c1f7ca
...
...
@@ -51,13 +51,16 @@ describe Clusters::Applications::Prometheus do
context
'cluster has kubeclient'
do
let
(
:kubernetes_url
)
{
'http://example.com'
}
let
(
:k8s_discover_response
)
{
{
resources:
[
{
name:
'service'
,
kind:
'Service'
}]
}
}
let
(
:k8s_discover_response
)
do
{
resources:
[
{
name:
'service'
,
kind:
'Service'
}
]
}
end
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
context
'with cluster for all environments without prometheus installed'
do
context
'without environment supplied'
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
...
...
@@ -224,7 +224,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
let!
(
:environment
)
{
create
(
:environment
,
project:
project
,
name:
'prod'
)
}
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
...
...
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