Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3dda2616
Commit
3dda2616
authored
Jul 04, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrated Geo checks to SystemChecks
parent
60fbb4bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
113 deletions
+122
-113
lib/system_check/geo/enabled_check.rb
lib/system_check/geo/enabled_check.rb
+19
-0
lib/system_check/geo/http_connection_check.rb
lib/system_check/geo/http_connection_check.rb
+78
-0
lib/system_check/geo/license_check.rb
lib/system_check/geo/license_check.rb
+19
-0
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+6
-113
No files found.
lib/system_check/geo/enabled_check.rb
0 → 100644
View file @
3dda2616
module
SystemCheck
module
Geo
class
EnabledCheck
<
SystemCheck
::
BaseCheck
set_name
'GitLab Geo is enabled'
def
check?
Gitlab
::
Geo
.
enabled?
end
def
show_error
try_fixing_it
(
'Follow Geo Setup instructions to configure primary and secondary nodes'
)
for_more_information
(
'doc/gitlab-geo/README.md'
)
end
end
end
end
lib/system_check/geo/http_connection_check.rb
0 → 100644
View file @
3dda2616
module
SystemCheck
module
Geo
class
HttpConnectionCheck
<
SystemCheck
::
BaseCheck
set_name
'GitLab Geo HTTP(S) connectivity'
set_skip_reason
'Geo is not enabled'
def
skip?
!
Gitlab
::
Geo
.
enabled?
end
def
multi_check
puts
if
Gitlab
::
Geo
.
primary?
Gitlab
::
Geo
.
secondary_nodes
.
each
do
|
node
|
print
"* Can connect to secondary node: '
#{
node
.
url
}
' ... "
check_gitlab_geo_node
(
node
)
end
end
if
Gitlab
::
Geo
.
secondary?
print
'* Can connect to the primary node ... '
check_gitlab_geo_node
(
Gitlab
::
Geo
.
primary_node
)
end
end
def
check_gitlab_geo_node
(
node
)
display_error
=
proc
do
|
e
|
puts
'no'
.
color
(
:red
)
puts
' Reason:'
.
color
(
:blue
)
puts
"
#{
e
.
message
}
"
end
begin
response
=
Net
::
HTTP
.
start
(
node
.
uri
.
host
,
node
.
uri
.
port
,
use_ssl:
(
node
.
uri
.
scheme
==
'https'
))
do
|
http
|
http
.
request
(
Net
::
HTTP
::
Get
.
new
(
node
.
uri
))
end
if
response
.
code_type
==
Net
::
HTTPFound
puts
'yes'
.
color
(
:green
)
else
puts
'no'
.
color
(
:red
)
end
rescue
Errno
::
ECONNREFUSED
=>
e
display_error
.
call
(
e
)
try_fixing_it
(
'Check if the machine is online and GitLab is running'
,
'Check your firewall rules and make sure this machine can reach the target machine'
,
"Make sure port and protocol are correct: '
#{
node
.
url
}
', or change it in Admin > Geo Nodes"
)
rescue
SocketError
=>
e
display_error
.
call
(
e
)
if
e
.
cause
&&
e
.
cause
.
message
.
starts_with?
(
'getaddrinfo'
)
try_fixing_it
(
'Check if your machine can connect to a DNS server'
,
"Check if your machine can resolve DNS for: '
#{
node
.
uri
.
host
}
'"
,
'If machine host is incorrect, change it in Admin > Geo Nodes'
)
end
rescue
OpenSSL
::
SSL
::
SSLError
=>
e
display_error
.
call
(
e
)
try_fixing_it
(
'If you have a self-signed CA or certificate you need to whitelist it in Omnibus'
)
for_more_information
(
see_custom_certificate_doc
)
try_fixing_it
(
'If you have a valid certificate make sure you have the full certificate chain in the pem file'
)
rescue
Exception
=>
e
# rubocop:disable Lint/RescueException
display_error
.
call
(
e
)
end
end
end
end
end
lib/system_check/geo/license_check.rb
0 → 100644
View file @
3dda2616
module
SystemCheck
module
Geo
class
LicenseCheck
<
SystemCheck
::
BaseCheck
set_name
'GitLab Geo is available'
def
check?
Gitlab
::
Geo
.
license_allows?
end
def
show_error
try_fixing_it
(
'Upload a new license that includes GitLab Geo feature'
)
for_more_information
(
'https://about.gitlab.com/features/gitlab-geo/'
)
end
end
end
end
lib/tasks/gitlab/check.rake
View file @
3dda2616
...
...
@@ -545,76 +545,20 @@ namespace :gitlab do
desc
'GitLab | Check Geo configuration and dependencies'
task
check: :environment
do
warn_user_is_not_gitlab
start_checking
'Geo'
check_geo_license
check_geo_enabled
check_nodes_http_connection
finished_checking
'Geo'
end
# Checks
########################
def
check_geo_license
print
'GitLab Geo is available ... '
if
Gitlab
::
Geo
.
license_allows?
puts
'yes'
.
color
(
:green
)
else
puts
'no'
.
color
(
:red
)
try_fixing_it
(
'Upload a new license that includes GitLab Geo feature'
)
for_more_information
(
see_geo_features_page
)
end
end
def
check_geo_enabled
print
'GitLab Geo is enabled ... '
if
Gitlab
::
Geo
.
enabled?
puts
'yes'
.
color
(
:green
)
else
puts
'no'
.
color
(
:red
)
try_fixing_it
(
'Follow Geo Setup instructions to configure primary and secondary nodes'
)
for_more_information
(
see_geo_docs
)
end
end
def
check_nodes_http_connection
return
unless
Gitlab
::
Geo
.
enabled?
if
Gitlab
::
Geo
.
primary?
Gitlab
::
Geo
.
secondary_nodes
.
each
do
|
node
|
print
"Can connect to secondary node: '
#{
node
.
url
}
' ... "
check_gitlab_geo_node
(
node
)
end
end
checks
=
[
SystemCheck
::
Geo
::
LicenseCheck
,
SystemCheck
::
Geo
::
EnabledCheck
,
SystemCheck
::
Geo
::
HttpConnectionCheck
]
if
Gitlab
::
Geo
.
secondary?
print
'Can connect to the primary node ... '
check_gitlab_geo_node
(
Gitlab
::
Geo
.
primary_node
)
end
SystemCheck
.
run
(
'Geo'
,
checks
)
end
end
# Helper methods
##########################
def
see_geo_features_page
'https://about.gitlab.com/features/gitlab-geo/'
end
def
see_geo_docs
'doc/gitlab-geo/README.md'
end
def
see_custom_certificate_doc
'https://docs.gitlab.com/omnibus/common_installation_problems/README.html#using-self-signed-certificate-or-custom-certificate-authorities'
end
...
...
@@ -661,55 +605,4 @@ namespace :gitlab do
puts
"No ref lock files exist"
.
color
(
:green
)
end
end
def
check_gitlab_geo_node
(
node
)
display_error
=
proc
do
|
e
|
puts
'no'
.
color
(
:red
)
puts
' Reason:'
.
color
(
:blue
)
puts
"
#{
e
.
message
}
"
end
begin
response
=
Net
::
HTTP
.
start
(
node
.
uri
.
host
,
node
.
uri
.
port
,
use_ssl:
(
node
.
uri
.
scheme
==
'https'
))
do
|
http
|
http
.
request
(
Net
::
HTTP
::
Get
.
new
(
node
.
uri
))
end
if
response
.
code_type
==
Net
::
HTTPFound
puts
'yes'
.
color
(
:green
)
else
puts
'no'
.
color
(
:red
)
end
rescue
Errno
::
ECONNREFUSED
=>
e
display_error
.
call
(
e
)
try_fixing_it
(
'Check if the machine is online and GitLab is running'
,
'Check your firewall rules and make sure this machine can reach the target machine'
,
"Make sure port and protocol are correct: '
#{
node
.
url
}
', or change it in Admin > Geo Nodes"
)
rescue
SocketError
=>
e
display_error
.
call
(
e
)
if
e
.
cause
&&
e
.
cause
.
message
.
starts_with?
(
'getaddrinfo'
)
try_fixing_it
(
'Check if your machine can connect to a DNS server'
,
"Check if your machine can resolve DNS for: '
#{
node
.
uri
.
host
}
'"
,
'If machine host is incorrect, change it in Admin > Geo Nodes'
)
end
rescue
OpenSSL
::
SSL
::
SSLError
=>
e
display_error
.
call
(
e
)
try_fixing_it
(
'If you have a self-signed CA or certificate you need to whitelist it in Omnibus'
)
for_more_information
(
see_custom_certificate_doc
)
try_fixing_it
(
'If you have a valid certificate make sure you have the full certificate chain in the pem file'
)
rescue
Exception
=>
e
# rubocop:disable Lint/RescueException
display_error
.
call
(
e
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment