Commit 6ecb6316 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fix codestyle

parent 3dda2616
...@@ -9,69 +9,69 @@ module SystemCheck ...@@ -9,69 +9,69 @@ module SystemCheck
end end
def multi_check def multi_check
puts $stdout.puts
if Gitlab::Geo.primary? if Gitlab::Geo.primary?
Gitlab::Geo.secondary_nodes.each do |node| Gitlab::Geo.secondary_nodes.each do |node|
print "* Can connect to secondary node: '#{node.url}' ... " $stdout.print "* Can connect to secondary node: '#{node.url}' ... "
check_gitlab_geo_node(node) check_gitlab_geo_node(node)
end end
end end
if Gitlab::Geo.secondary? if Gitlab::Geo.secondary?
print '* Can connect to the primary node ... ' $stdout.print '* Can connect to the primary node ... '
check_gitlab_geo_node(Gitlab::Geo.primary_node) check_gitlab_geo_node(Gitlab::Geo.primary_node)
end end
end end
private
def check_gitlab_geo_node(node) def check_gitlab_geo_node(node)
display_error = proc do |e| response = Net::HTTP.start(node.uri.host, node.uri.port, use_ssl: (node.uri.scheme == 'https')) do |http|
puts 'no'.color(:red) http.request(Net::HTTP::Get.new(node.uri))
puts ' Reason:'.color(:blue)
puts " #{e.message}"
end end
begin if response.code_type == Net::HTTPFound
response = Net::HTTP.start(node.uri.host, node.uri.port, use_ssl: (node.uri.scheme == 'https')) do |http| $stdout.puts 'yes'.color(:green)
http.request(Net::HTTP::Get.new(node.uri)) else
end $stdout.puts 'no'.color(:red)
end
rescue Errno::ECONNREFUSED => e
display_exception(e)
if response.code_type == Net::HTTPFound try_fixing_it(
puts 'yes'.color(:green) 'Check if the machine is online and GitLab is running',
else 'Check your firewall rules and make sure this machine can reach the target machine',
puts 'no'.color(:red) "Make sure port and protocol are correct: '#{node.url}', or change it in Admin > Geo Nodes"
end )
rescue Errno::ECONNREFUSED => e rescue SocketError => e
display_error.call(e) display_exception(e)
if e.cause && e.cause.message.starts_with?('getaddrinfo')
try_fixing_it( try_fixing_it(
'Check if the machine is online and GitLab is running', 'Check if your machine can connect to a DNS server',
'Check your firewall rules and make sure this machine can reach the target machine', "Check if your machine can resolve DNS for: '#{node.uri.host}'",
"Make sure port and protocol are correct: '#{node.url}', or change it in Admin > Geo Nodes" 'If machine host is incorrect, change it in Admin > Geo Nodes'
) )
rescue SocketError => e end
display_error.call(e) rescue OpenSSL::SSL::SSLError => e
display_exception(e)
if e.cause && e.cause.message.starts_with?('getaddrinfo') try_fixing_it(
try_fixing_it( 'If you have a self-signed CA or certificate you need to whitelist it in Omnibus'
'Check if your machine can connect to a DNS server', )
"Check if your machine can resolve DNS for: '#{node.uri.host}'", for_more_information(see_custom_certificate_doc)
'If machine host is incorrect, change it in Admin > Geo Nodes'
)
end
rescue OpenSSL::SSL::SSLError => e
display_error.call(e)
try_fixing_it( try_fixing_it(
'If you have a self-signed CA or certificate you need to whitelist it in Omnibus' 'If you have a valid certificate make sure you have the full certificate chain in the pem file'
) )
for_more_information(see_custom_certificate_doc) rescue StandardError => e
display_exception(e)
end
try_fixing_it( def display_exception(exception)
'If you have a valid certificate make sure you have the full certificate chain in the pem file' $stdout.puts 'no'.color(:red)
) $stdout.puts ' Reason:'.color(:blue)
rescue Exception => e # rubocop:disable Lint/RescueException $stdout.puts " #{exception.message}"
display_error.call(e)
end
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