Show error when can't connect on Geo Node to get information

[ci skip]
parent 3ef4154f
......@@ -10,27 +10,26 @@ class GeoNodePresenter < Gitlab::View::Presenter::Delegated
end
def repositories
status.repositories
status.repositories.to_i
end
def repositories_synced
status.repositories_synced
status.repositories_synced.to_i
end
def repositories_synced_in_percentage
return 0 if repositories === 0
(repositories_synced.to_f / repositories.to_f) * 100.0
end
def repositories_failed
status.repositories_failed
status.repositories_failed.to_i
end
private
def status
@status ||= begin
_, status = Geo::NodeStatusService.new.call(status_url)
status
end
@status ||= Geo::NodeStatusService.new.call(status_url)
end
end
......@@ -12,13 +12,17 @@ module Geo
'PRIVATE-TOKEN' => private_token
})
keys = GeoNode::Status.members.map(&:to_s)
values = response.parsed_response.values_at(*keys)
status = GeoNode::Status.new(*values)
values =
if response.code >= 200 && response.code < 300
keys = GeoNode::Status.members.map(&:to_s)
response.parsed_response.values_at(*keys)
else
["Could not connect to Geo node - HTTP Status Code: #{response.code}"]
end
[(response.code >= 200 && response.code < 300), status]
GeoNode::Status.new(*values)
rescue HTTParty::Error, Errno::ECONNREFUSED => e
[false, GeoNode::Status.new(ActionView::Base.full_sanitizer.sanitize(e.message))]
GeoNode::Status.new(ActionView::Base.full_sanitizer.sanitize(e.message))
end
private
......
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