Commit f67f17a8 authored by Max Woolf's avatar Max Woolf

Merge branch 'mk/fix-geo-http-connection-check' into 'master'

Fix too many redirects during Geo check task

See merge request gitlab-org/gitlab!64265
parents d939d3d8 6d80e6a8
......@@ -33,7 +33,7 @@ module SystemCheck
private
def check_gitlab_geo_node(node)
response = Gitlab::HTTP.get(node.internal_uri, allow_local_requests: true)
response = Gitlab::HTTP.get(node.internal_uri, allow_local_requests: true, limit: 10)
if response.code_type == Net::HTTPOK
$stdout.puts 'yes'.color(:green)
......
......@@ -39,6 +39,41 @@ RSpec.describe SystemCheck::Geo::HttpConnectionCheck do
end
end
context 'redirects' do
def stub_many_requests(num_redirects)
url = primary_node.internal_uri
location = "https://example.com"
num_redirects.times do |index|
next_url = "#{location}/#{index}"
stub_request(http_method, url).to_return(status: 301, headers: { 'Location' => next_url })
url = next_url
end
stub_request(http_method, url).to_return(status: 200, body: "", headers: {})
end
context 'connection succeeds after 9 redirects' do
it 'puts yes' do
stub_many_requests(9)
expect do
subject.multi_check
end.to output("\n* Can connect to the primary node ... yes\n").to_stdout
end
end
context 'connection would succeed after 10 redirects' do
it 'puts no' do
stub_many_requests(10)
expect do
subject.multi_check
end.to output("\n* Can connect to the primary node ... no\n Reason:\n Gitlab::HTTP::RedirectionTooDeep\n").to_stdout
end
end
end
context 'connection errored' do
it 'puts no if check errored' do
stub_request(http_method, primary_node.internal_uri).to_return(status: 400, body: "", headers: {})
......
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