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
2df37bf2
Commit
2df37bf2
authored
May 25, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if Geo secondary role is enabled rather than database config file
parent
0a7c7d25
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
15 deletions
+25
-15
app/workers/geo_file_download_dispatch_worker.rb
app/workers/geo_file_download_dispatch_worker.rb
+1
-1
app/workers/geo_repository_sync_worker.rb
app/workers/geo_repository_sync_worker.rb
+12
-2
lib/api/geo.rb
lib/api/geo.rb
+1
-1
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+0
-4
lib/gitlab/geo/health_check.rb
lib/gitlab/geo/health_check.rb
+5
-1
spec/requests/api/geo_spec.rb
spec/requests/api/geo_spec.rb
+2
-2
spec/workers/geo_file_download_dispatch_worker_spec.rb
spec/workers/geo_file_download_dispatch_worker_spec.rb
+2
-2
spec/workers/geo_repository_sync_worker_spec.rb
spec/workers/geo_repository_sync_worker_spec.rb
+2
-2
No files found.
app/workers/geo_file_download_dispatch_worker.rb
View file @
2df37bf2
...
...
@@ -22,7 +22,7 @@ class GeoFileDownloadDispatchWorker
# files, excluding ones in progress.
# 5. Quit when we have scheduled all downloads or exceeded an hour.
def
perform
return
unless
Gitlab
::
Geo
.
configur
ed?
return
unless
Gitlab
::
Geo
.
secondary_role_enabl
ed?
return
unless
Gitlab
::
Geo
.
secondary?
@start_time
=
Time
.
now
...
...
app/workers/geo_repository_sync_worker.rb
View file @
2df37bf2
...
...
@@ -7,7 +7,7 @@ class GeoRepositorySyncWorker
LAST_SYNC_INTERVAL
=
24
.
hours
def
perform
return
unless
Gitlab
::
Geo
.
configur
ed?
return
unless
Gitlab
::
Geo
.
secondary_role_enabl
ed?
return
unless
Gitlab
::
Geo
.
primary_node
.
present?
start_time
=
Time
.
now
...
...
@@ -20,7 +20,7 @@ class GeoRepositorySyncWorker
project_ids
.
each
do
|
project_id
|
begin
break
if
over_time?
(
start_time
)
break
unless
Gitlab
::
Geo
.
current_
node_enabled?
break
unless
node_enabled?
# We try to obtain a lease here for the entire sync process because we
# want to sync the repositories continuously at a controlled rate
...
...
@@ -73,6 +73,16 @@ class GeoRepositorySyncWorker
Time
.
now
-
start_time
>=
RUN_TIME
end
def
node_enabled?
# Only check every minute to avoid polling the DB excessively
unless
@last_enabled_check
.
present?
&&
(
Time
.
now
-
@last_enabled_check
>
1
.
minute
)
@last_enabled_check
=
Time
.
now
@current_node_enabled
=
nil
end
@current_node_enabled
||=
Gitlab
::
Geo
.
current_node_enabled?
end
def
try_obtain_lease
lease
=
Gitlab
::
ExclusiveLease
.
new
(
lease_key
,
timeout:
lease_timeout
).
try_obtain
...
...
lib/api/geo.rb
View file @
2df37bf2
...
...
@@ -112,7 +112,7 @@ module API
end
def
require_node_to_have_tracking_db!
not_found!
'Geo node does not have its tracking database enabled.'
unless
Gitlab
::
Geo
.
configur
ed?
not_found!
'Geo node does not have its tracking database enabled.'
unless
Gitlab
::
Geo
.
secondary_role_enabl
ed?
end
end
end
...
...
lib/gitlab/geo.rb
View file @
2df37bf2
...
...
@@ -42,10 +42,6 @@ module Gitlab
Gitlab
::
Geo
.
current_node
.
reload
.
enabled?
end
def
self
.
configured?
Rails
.
configuration
.
respond_to?
(
:geo_database
)
end
def
self
.
primary_role_enabled?
Gitlab
.
config
.
geo_primary_role
[
'enable'
]
end
...
...
lib/gitlab/geo/health_check.rb
View file @
2df37bf2
...
...
@@ -3,7 +3,7 @@ module Gitlab
class
HealthCheck
def
self
.
perform_checks
return
''
unless
Gitlab
::
Geo
.
secondary?
return
'The Geo database configuration file is missing.'
unless
Gitlab
::
Geo
.
configured?
return
'The Geo database configuration file is missing.'
unless
self
.
geo_database_
configured?
return
'The Geo node has a database that is not configured for streaming replication with the primary node.'
unless
self
.
database_secondary?
database_version
=
self
.
get_database_version
.
to_i
...
...
@@ -57,6 +57,10 @@ module Gitlab
.
first
.
fetch
(
'pg_is_in_recovery'
)
==
't'
end
def
self
.
geo_database_configured?
Rails
.
configuration
.
respond_to?
(
:geo_database
)
end
end
end
end
spec/requests/api/geo_spec.rb
View file @
2df37bf2
...
...
@@ -308,8 +308,8 @@ describe API::Geo, api: true do
expect
(
response
).
to
match_response_schema
(
'geo_node_status'
)
end
it
'responds with a 404 when the
tracking databas
e is disabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:
configur
ed?
).
and_return
(
false
)
it
'responds with a 404 when the
secondary rol
e is disabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:
secondary_role_enabl
ed?
).
and_return
(
false
)
get
api
(
'/geo/status'
),
nil
,
request
.
headers
...
...
spec/workers/geo_file_download_dispatch_worker_spec.rb
View file @
2df37bf2
...
...
@@ -13,10 +13,10 @@ describe GeoFileDownloadDispatchWorker do
subject
{
described_class
.
new
}
describe
'#perform'
do
it
'does not schedule anything when
tracking DB is not available
'
do
it
'does not schedule anything when
secondary role is disabled
'
do
create
(
:lfs_object
,
:with_file
)
allow
(
Rails
.
configuration
).
to
receive
(
:respond_to?
).
with
(
:geo_database
)
{
false
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_role_enabled?
)
{
false
}
expect
(
GeoFileDownloadWorker
).
not_to
receive
(
:perform_async
)
...
...
spec/workers/geo_repository_sync_worker_spec.rb
View file @
2df37bf2
...
...
@@ -52,8 +52,8 @@ describe GeoRepositorySyncWorker do
subject
.
perform
end
it
'does not perform Geo::RepositorySyncService when
tracking DB is not available
'
do
allow
(
Rails
.
configuration
).
to
receive
(
:respond_to?
).
with
(
:geo_database
)
{
false
}
it
'does not perform Geo::RepositorySyncService when
secondary role is disabled
'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_role_enabled?
)
{
false
}
expect
(
Geo
::
RepositorySyncService
).
not_to
receive
(
:new
)
...
...
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