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
02ff3334
Commit
02ff3334
authored
Mar 16, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Populate the tracking DB for projects synced before upgrade to 9.0
parent
a67245a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
app/workers/geo_backfill_worker.rb
app/workers/geo_backfill_worker.rb
+22
-1
spec/workers/geo_backfill_worker_spec.rb
spec/workers/geo_backfill_worker_spec.rb
+20
-4
No files found.
app/workers/geo_backfill_worker.rb
View file @
02ff3334
...
...
@@ -51,7 +51,18 @@ class GeoBackfillWorker
end
def
synced?
(
project
)
project
.
repository_exists?
||
registry_exists?
(
project
)
return
true
if
registry_exists?
(
project
)
return
false
unless
project
.
repository
.
exists?
return
false
if
project
.
repository
.
exists?
&&
project
.
repository
.
empty?
# When Geo customers upgrade to 9.0, the secondaries nodes that are enabled
# will start the backfilling process automatically. We need to populate the
# tracking database correctly for projects synced before. Otherwise, the
# query to retrieve the projects will always return the same 100 projects
# because they don't have entries in the tracking database.
create_missing_registry
(
project
)
true
end
def
registry_exists?
(
project
)
...
...
@@ -60,6 +71,16 @@ class GeoBackfillWorker
.
any?
end
def
create_missing_registry
(
project
)
logger
.
info
"Creating missing registry for project
#{
project
.
path_with_namespace
}
(
#{
project
.
id
}
)"
Geo
::
ProjectRegistry
.
create
(
project_id:
project
.
id
,
last_repository_synced_at:
DateTime
.
now
,
last_repository_successful_sync_at:
DateTime
.
now
)
end
def
try_obtain_lease
lease
=
Gitlab
::
ExclusiveLease
.
new
(
lease_key
,
timeout:
lease_timeout
).
try_obtain
...
...
spec/workers/geo_backfill_worker_spec.rb
View file @
02ff3334
...
...
@@ -26,12 +26,28 @@ describe Geo::GeoBackfillWorker, services: true do
subject
.
perform
end
it
'does not perform Geo::RepositoryBackfillService for projects that repository exists'
do
create_list
(
:project
,
2
)
context
'when repository exists'
do
it
'does not perform Geo::RepositoryBackfillService for non empty repositories'
do
create_list
(
:project
,
2
)
expect
(
Geo
::
RepositoryBackfillService
).
to
receive
(
:new
).
twice
.
and_return
(
spy
)
expect
(
Geo
::
RepositoryBackfillService
).
to
receive
(
:new
).
twice
.
and_return
(
spy
)
subject
.
perform
subject
.
perform
end
it
'performs Geo::RepositoryBackfillService for empty repositories'
do
create
(
:empty_project
)
expect
(
Geo
::
RepositoryBackfillService
).
to
receive
(
:new
).
exactly
(
3
).
times
.
and_return
(
spy
)
subject
.
perform
end
it
'creates missing registry for non empty repositories'
do
create
(
:project
)
expect
{
subject
.
perform
}.
to
change
(
Geo
::
ProjectRegistry
,
:count
).
by
(
3
)
end
end
it
'does not perform Geo::RepositoryBackfillService when can not obtain a lease'
do
...
...
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