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
19812e3e
Commit
19812e3e
authored
Jun 20, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make queries not die when underlying data cannot be found
parent
15b7b9ec
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
46 deletions
+50
-46
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
...prometheus/queries/additional_metrics_deployment_query.rb
+9
-8
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
...rometheus/queries/additional_metrics_environment_query.rb
+9
-8
lib/gitlab/prometheus/queries/deployment_query.rb
lib/gitlab/prometheus/queries/deployment_query.rb
+17
-16
lib/gitlab/prometheus/queries/environment_query.rb
lib/gitlab/prometheus/queries/environment_query.rb
+13
-12
spec/controllers/projects/deployments_controller_spec.rb
spec/controllers/projects/deployments_controller_spec.rb
+2
-2
No files found.
lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
View file @
19812e3e
...
@@ -5,7 +5,7 @@ module Gitlab
...
@@ -5,7 +5,7 @@ module Gitlab
include
QueryAdditionalMetrics
include
QueryAdditionalMetrics
def
query
(
deployment_id
)
def
query
(
deployment_id
)
deployment
=
Deployment
.
find_by
(
id:
deployment_id
)
Deployment
.
find_by
(
id:
deployment_id
).
try
do
|
deployment
|
query_context
=
{
query_context
=
{
environment_slug:
deployment
.
environment
.
slug
,
environment_slug:
deployment
.
environment
.
slug
,
environment_filter:
%{container_name!="POD",environment="#{deployment.environment.slug}"}
,
environment_filter:
%{container_name!="POD",environment="#{deployment.environment.slug}"}
,
...
@@ -18,4 +18,5 @@ module Gitlab
...
@@ -18,4 +18,5 @@ module Gitlab
end
end
end
end
end
end
end
end
end
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
View file @
19812e3e
...
@@ -5,7 +5,7 @@ module Gitlab
...
@@ -5,7 +5,7 @@ module Gitlab
include
QueryAdditionalMetrics
include
QueryAdditionalMetrics
def
query
(
environment_id
)
def
query
(
environment_id
)
environment
=
Environment
.
find_by
(
id:
environment_id
)
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
query_context
=
{
query_context
=
{
environment_slug:
environment
.
slug
,
environment_slug:
environment
.
slug
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
,
environment_filter:
%{container_name!="POD",environment="#{environment.slug}"}
,
...
@@ -18,4 +18,5 @@ module Gitlab
...
@@ -18,4 +18,5 @@ module Gitlab
end
end
end
end
end
end
end
end
end
lib/gitlab/prometheus/queries/deployment_query.rb
View file @
19812e3e
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
module
Queries
module
Queries
class
DeploymentQuery
<
BaseQuery
class
DeploymentQuery
<
BaseQuery
def
query
(
deployment_id
)
def
query
(
deployment_id
)
deployment
=
Deployment
.
find_by
(
id:
deployment_id
)
Deployment
.
find_by
(
id:
deployment_id
).
try
do
|
deployment
|
environment_slug
=
deployment
.
environment
.
slug
environment_slug
=
deployment
.
environment
.
slug
memory_query
=
raw_memory_usage_query
(
environment_slug
)
memory_query
=
raw_memory_usage_query
(
environment_slug
)
...
@@ -27,4 +27,5 @@ module Gitlab
...
@@ -27,4 +27,5 @@ module Gitlab
end
end
end
end
end
end
end
end
end
lib/gitlab/prometheus/queries/environment_query.rb
View file @
19812e3e
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
module
Queries
module
Queries
class
EnvironmentQuery
<
BaseQuery
class
EnvironmentQuery
<
BaseQuery
def
query
(
environment_id
)
def
query
(
environment_id
)
environment
=
Environment
.
find_by
(
id:
environment_id
)
Environment
.
find_by
(
id:
environment_id
).
try
do
|
environment
|
environment_slug
=
environment
.
slug
environment_slug
=
environment
.
slug
timeframe_start
=
8
.
hours
.
ago
.
to_f
timeframe_start
=
8
.
hours
.
ago
.
to_f
timeframe_end
=
Time
.
now
.
to_f
timeframe_end
=
Time
.
now
.
to_f
...
@@ -21,4 +21,5 @@ module Gitlab
...
@@ -21,4 +21,5 @@ module Gitlab
end
end
end
end
end
end
end
end
end
spec/controllers/projects/deployments_controller_spec.rb
View file @
19812e3e
...
@@ -141,7 +141,7 @@ describe Projects::DeploymentsController do
...
@@ -141,7 +141,7 @@ describe Projects::DeploymentsController do
end
end
it
'returns a empty response 204 response'
do
it
'returns a empty response 204 response'
do
get
:additional_metrics
,
deployment_params
(
id:
deployment
.
id
)
get
:additional_metrics
,
deployment_params
(
id:
deployment
.
id
,
format: :json
)
expect
(
response
).
to
have_http_status
(
204
)
expect
(
response
).
to
have_http_status
(
204
)
expect
(
response
.
body
).
to
eq
(
''
)
expect
(
response
.
body
).
to
eq
(
''
)
end
end
...
@@ -161,7 +161,7 @@ describe Projects::DeploymentsController do
...
@@ -161,7 +161,7 @@ describe Projects::DeploymentsController do
end
end
it
'returns a metrics JSON document'
do
it
'returns a metrics JSON document'
do
get
:additional_metrics
,
deployment_params
(
id:
deployment
.
id
)
get
:additional_metrics
,
deployment_params
(
id:
deployment
.
id
,
format: :json
)
expect
(
response
).
to
be_ok
expect
(
response
).
to
be_ok
expect
(
json_response
[
'success'
]).
to
be
(
true
)
expect
(
json_response
[
'success'
]).
to
be
(
true
)
...
...
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