Rescue Kubeclient::HttpError when generating prometheus_client

This commit is contained in:
Shinya Maeda 2018-05-16 21:35:24 +09:00
parent ad9e00917f
commit c1e8949237
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,11 @@ module Clusters
# ensures headers containing auth data are appended to original k8s client options
options = kube_client.rest_client.options.merge(headers: kube_client.headers)
RestClient::Resource.new(proxy_url, options)
rescue Kubeclient::HttpError
# 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.
# Since `PrometheusAdapter#can_query?` is eargely loaded on environement pages in gitlab,
# we need to silence the exceptions
end
private