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
5fcd90ef
Commit
5fcd90ef
authored
Mar 06, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if project was already synced before syncing it
parent
9d39619d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
app/workers/geo_backfill_worker.rb
app/workers/geo_backfill_worker.rb
+17
-3
No files found.
app/workers/geo_backfill_worker.rb
View file @
5fcd90ef
...
...
@@ -8,18 +8,18 @@ class GeoBackfillWorker
def
perform
return
unless
Gitlab
::
Geo
.
primary_node
.
present?
start
=
Time
.
now
start
_time
=
Time
.
now
project_ids
=
find_project_ids
logger
.
info
"Started Geo backfilling for
#{
project_ids
.
length
}
project(s)"
project_ids
.
each
do
|
project_id
|
begin
break
if
Time
.
now
-
start
>=
RUN_TIME
break
if
over_time?
(
start_time
)
break
unless
node_enabled?
project
=
Project
.
find
(
project_id
)
next
if
project
.
repository_exists?
next
if
synced?
(
project
)
try_obtain_lease
do
|
lease
|
GeoSingleRepositoryBackfillWorker
.
new
.
perform
(
project_id
,
lease
)
...
...
@@ -43,6 +43,20 @@ class GeoBackfillWorker
.
pluck
(
:id
)
end
def
over_time?
(
start_time
)
Time
.
now
-
start_time
>=
RUN_TIME
end
def
synced?
(
project
)
project
.
repository_exists?
||
registry_exists?
(
project
)
end
def
registry_exists?
(
project
)
Geo
::
ProjectRegistry
.
where
(
project_id:
project
.
id
)
.
where
.
not
(
last_repository_synced_at:
nil
)
.
any?
end
def
try_obtain_lease
lease
=
Gitlab
::
ExclusiveLease
.
new
(
lease_key
,
timeout:
lease_timeout
).
try_obtain
...
...
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