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
c1b937b2
Commit
c1b937b2
authored
Aug 17, 2020
by
Matthias Kaeppler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reinstate 60s timeout in Cluster Prometheus
parent
2ca202df
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
10 deletions
+27
-10
app/models/clusters/applications/prometheus.rb
app/models/clusters/applications/prometheus.rb
+3
-1
app/models/concerns/prometheus_adapter.rb
app/models/concerns/prometheus_adapter.rb
+11
-0
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+3
-7
changelogs/unreleased/232786-reinstate-60s-timeout.yml
changelogs/unreleased/232786-reinstate-60s-timeout.yml
+5
-0
spec/models/clusters/applications/prometheus_spec.rb
spec/models/clusters/applications/prometheus_spec.rb
+5
-2
No files found.
app/models/clusters/applications/prometheus.rb
View file @
c1b937b2
...
@@ -106,7 +106,9 @@ module Clusters
...
@@ -106,7 +106,9 @@ module Clusters
proxy_url
=
kube_client
.
proxy_url
(
'service'
,
service_name
,
service_port
,
Gitlab
::
Kubernetes
::
Helm
::
NAMESPACE
)
proxy_url
=
kube_client
.
proxy_url
(
'service'
,
service_name
,
service_port
,
Gitlab
::
Kubernetes
::
Helm
::
NAMESPACE
)
# ensures headers containing auth data are appended to original k8s client options
# ensures headers containing auth data are appended to original k8s client options
options
=
kube_client
.
rest_client
.
options
.
merge
(
headers:
kube_client
.
headers
)
options
=
kube_client
.
rest_client
.
options
.
merge
(
prometheus_client_default_options
)
.
merge
(
headers:
kube_client
.
headers
)
Gitlab
::
PrometheusClient
.
new
(
proxy_url
,
options
)
Gitlab
::
PrometheusClient
.
new
(
proxy_url
,
options
)
rescue
Kubeclient
::
HttpError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Errno
::
ENETUNREACH
rescue
Kubeclient
::
HttpError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Errno
::
ENETUNREACH
# If users have mistakenly set parameters or removed the depended clusters,
# If users have mistakenly set parameters or removed the depended clusters,
...
...
app/models/concerns/prometheus_adapter.rb
View file @
c1b937b2
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
module
PrometheusAdapter
module
PrometheusAdapter
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
# We should choose more conservative timeouts, but some queries we run are now busting our
# default timeouts, which are stricter. We should make those queries faster instead.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/232786
DEFAULT_PROMETHEUS_REQUEST_TIMEOUT_SEC
=
60
.
seconds
included
do
included
do
include
ReactiveCaching
include
ReactiveCaching
...
@@ -15,6 +20,12 @@ module PrometheusAdapter
...
@@ -15,6 +20,12 @@ module PrometheusAdapter
raise
NotImplementedError
raise
NotImplementedError
end
end
def
prometheus_client_default_options
{
timeout:
DEFAULT_PROMETHEUS_REQUEST_TIMEOUT_SEC
}
end
# This is a light-weight check if a prometheus client is properly configured.
# This is a light-weight check if a prometheus client is properly configured.
def
configured?
def
configured?
raise
NotImplemented
raise
NotImplemented
...
...
app/models/project_services/prometheus_service.rb
View file @
c1b937b2
...
@@ -97,13 +97,9 @@ class PrometheusService < MonitoringService
...
@@ -97,13 +97,9 @@ class PrometheusService < MonitoringService
def
prometheus_client
def
prometheus_client
return
unless
should_return_client?
return
unless
should_return_client?
options
=
{
options
=
prometheus_client_default_options
.
merge
(
allow_local_requests:
allow_local_api_url?
,
allow_local_requests:
allow_local_api_url?
# We should choose more conservative timeouts, but some queries we run are now busting our
)
# default timeouts, which are stricter. We should make those queries faster instead.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/233109
timeout:
60
}
if
behind_iap?
if
behind_iap?
# Adds the Authorization header
# Adds the Authorization header
...
...
changelogs/unreleased/232786-reinstate-60s-timeout.yml
0 → 100644
View file @
c1b937b2
---
title
:
Reinstate 60s timeout in Cluster Prometheus
merge_request
:
39595
author
:
type
:
other
spec/models/clusters/applications/prometheus_spec.rb
View file @
c1b937b2
...
@@ -109,10 +109,13 @@ RSpec.describe Clusters::Applications::Prometheus do
...
@@ -109,10 +109,13 @@ RSpec.describe Clusters::Applications::Prometheus do
expect
(
subject
.
prometheus_client
).
to
be_instance_of
(
Gitlab
::
PrometheusClient
)
expect
(
subject
.
prometheus_client
).
to
be_instance_of
(
Gitlab
::
PrometheusClient
)
end
end
it
'
copies proxy_url, options and headers from kube client to prometheus_client
'
do
it
'
merges proxy_url, options and headers from kube client with prometheus_client options
'
do
expect
(
Gitlab
::
PrometheusClient
)
expect
(
Gitlab
::
PrometheusClient
)
.
to
(
receive
(
:new
))
.
to
(
receive
(
:new
))
.
with
(
a_valid_url
,
kube_client
.
rest_client
.
options
.
merge
(
headers:
kube_client
.
headers
))
.
with
(
a_valid_url
,
kube_client
.
rest_client
.
options
.
merge
({
headers:
kube_client
.
headers
,
timeout:
PrometheusAdapter
::
DEFAULT_PROMETHEUS_REQUEST_TIMEOUT_SEC
}))
subject
.
prometheus_client
subject
.
prometheus_client
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