Commit fc287da0 authored by Kirstie Cook's avatar Kirstie Cook

Silence exception when prometheus is unavailable

parent a1b0c955
...@@ -90,7 +90,7 @@ module Clusters ...@@ -90,7 +90,7 @@ module Clusters
# 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(headers: kube_client.headers)
Gitlab::PrometheusClient.new(proxy_url, options) Gitlab::PrometheusClient.new(proxy_url, options)
rescue Kubeclient::HttpError, Errno::ECONNRESET, Errno::ECONNREFUSED 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,
# `proxy_url` could raise an exception because gitlab can not communicate with the cluster. # `proxy_url` could raise an exception because gitlab can not communicate with the cluster.
# Since `PrometheusAdapter#can_query?` is eargely loaded on environement pages in gitlab, # Since `PrometheusAdapter#can_query?` is eargely loaded on environement pages in gitlab,
......
...@@ -117,6 +117,12 @@ describe Clusters::Applications::Prometheus do ...@@ -117,6 +117,12 @@ describe Clusters::Applications::Prometheus do
let(:exception) { Errno::ECONNRESET } let(:exception) { Errno::ECONNRESET }
end end
end end
context 'when the network is unreachable' do
it_behaves_like 'exception caught for prometheus client' do
let(:exception) { Errno::ENETUNREACH }
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment