Commit 4136a334 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'fix-prometheus-network-connectivity-error' into 'master'

Return 503 error when metrics dashboard has no connectivity

Closes #39162

See merge request gitlab-org/gitlab!22140
parents 56a7cabe df3c1882
...@@ -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,
......
---
title: Return 503 error when metrics dashboard has no connectivity
merge_request: 22140
author:
type: fixed
...@@ -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