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
80f6662a
Commit
80f6662a
authored
Mar 02, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load Geo DB only when Geo is enabled, and only if it is a secondary node
parent
9cfd10dd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
8 deletions
+28
-8
app/models/geo/base_registry.rb
app/models/geo/base_registry.rb
+3
-1
config/application.rb
config/application.rb
+3
-0
config/initializers/geo.rb
config/initializers/geo.rb
+4
-2
config/initializers/health_check.rb
config/initializers/health_check.rb
+4
-2
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+7
-2
lib/tasks/geo.rake
lib/tasks/geo.rake
+7
-1
No files found.
app/models/geo/base_registry.rb
View file @
80f6662a
class
Geo::BaseRegistry
<
ActiveRecord
::
Base
self
.
abstract_class
=
true
establish_connection
Rails
.
configuration
.
geo_database
if
Gitlab
::
Geo
.
secondary?
establish_connection
Rails
.
configuration
.
geo_database
end
end
config/application.rb
View file @
80f6662a
...
...
@@ -158,5 +158,8 @@ module Gitlab
config
.
generators
do
|
g
|
g
.
factory_girl
false
end
# This is needed for GitLab Geo
config
.
assets
.
initialize_on_precompile
=
false
end
end
config/initializers/geo.rb
View file @
80f6662a
Rails
.
application
.
configure
do
config
.
geo_database
=
config_for
(
:database_geo
)
if
Gitlab
::
Geo
.
secondary?
Rails
.
application
.
configure
do
config
.
geo_database
=
config_for
(
:database_geo
)
end
end
config/initializers/health_check.rb
View file @
80f6662a
...
...
@@ -2,7 +2,9 @@ HealthCheck.setup do |config|
config
.
standard_checks
=
%w(database migrations cache)
config
.
full_checks
=
%w(database migrations cache)
config
.
add_custom_check
(
'geo'
)
do
Gitlab
::
Geo
::
HealthCheck
.
perform_checks
if
Gitlab
::
Geo
.
secondary?
config
.
add_custom_check
(
'geo'
)
do
Gitlab
::
Geo
::
HealthCheck
.
perform_checks
end
end
end
lib/gitlab/geo.rb
View file @
80f6662a
...
...
@@ -19,7 +19,7 @@ module Gitlab
end
def
self
.
enabled?
self
.
cache_value
(
:geo_node_enabled
)
{
GeoNode
.
exists?
}
self
.
cache_value
(
:geo_node_enabled
)
{
self
.
connected_to_primary_db?
&&
GeoNode
.
exists?
}
end
def
self
.
license_allows?
...
...
@@ -31,7 +31,7 @@ module Gitlab
end
def
self
.
secondary?
self
.
cache_value
(
:geo_node_secondary
)
{
self
.
enabled?
&&
self
.
current_node
&&
!
self
.
current_node
.
prim
ary?
}
self
.
cache_value
(
:geo_node_secondary
)
{
self
.
enabled?
&&
self
.
current_node
&&
self
.
current_node
.
second
ary?
}
end
def
self
.
primary_ssh_path_prefix
...
...
@@ -80,5 +80,10 @@ module Gitlab
# urlsafe_base64 may return a string of size * 4/3
SecureRandom
.
urlsafe_base64
(
size
)[
0
,
size
]
end
def
self
.
connected_to_primary_db?
ActiveRecord
::
Base
.
connection
.
active?
&&
ActiveRecord
::
Base
.
connection
.
table_exists?
(
GeoNode
.
table_name
)
end
end
end
lib/tasks/geo.rake
View file @
80f6662a
...
...
@@ -24,13 +24,19 @@ namespace :geo do
# append and prepend proper tasks to all the tasks defined above
ns
.
tasks
.
each
do
|
task
|
task
.
enhance
[
'geo:config:set'
]
do
task
.
enhance
[
'geo:config:
check'
,
'geo:config:
set'
]
do
Rake
::
Task
[
'geo:config:restore'
].
invoke
end
end
end
namespace
:config
do
task
:check
do
unless
File
.
exist?
(
Rails
.
root
.
join
(
'config/database_geo.yml'
))
abort
(
'You should run these tasks only when GitLab Geo is enabled, and only if it is a secondary node'
)
end
end
task
:set
do
# save current configuration
@previous_config
=
{
...
...
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