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
99373c0d
Commit
99373c0d
authored
Mar 01, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle a RecordNotFound error when backfilling a repository
parent
8599ed03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
app/services/geo/repository_backfill_service.rb
app/services/geo/repository_backfill_service.rb
+10
-3
app/workers/geo_backfill_worker.rb
app/workers/geo_backfill_worker.rb
+13
-8
No files found.
app/services/geo/repository_backfill_service.rb
View file @
99373c0d
module
Geo
class
RepositoryBackfillService
attr_reader
:project
,
:backfill_lease
attr_reader
:project
_id
,
:backfill_lease
LEASE_TIMEOUT
=
8
.
hours
.
freeze
LEASE_KEY_PREFIX
=
'repository_backfill_service'
.
freeze
def
initialize
(
project_id
,
backfill_lease
)
@project
=
Project
.
find
(
project_id
)
@project
_id
=
project_id
@backfill_lease
=
backfill_lease
end
...
...
@@ -21,10 +21,18 @@ module Geo
log
(
'Finished repository sync'
)
end
end
rescue
ActiveRecord
::
RecordNotFound
logger
.
error
(
"Couldn't find project with ID=
#{
project_id
}
, skipping syncing"
)
ensure
Gitlab
::
ExclusiveLease
.
cancel
(
LEASE_KEY_PREFIX
,
backfill_lease
)
end
private
def
project
@project
||=
Project
.
find
(
project_id
)
end
def
fetch_repositories
started_at
=
DateTime
.
now
finished_at
=
nil
...
...
@@ -67,7 +75,6 @@ module Geo
log
(
'Releasing leases to sync repository'
)
Gitlab
::
ExclusiveLease
.
cancel
(
lease_key
,
repository_lease
)
Gitlab
::
ExclusiveLease
.
cancel
(
LEASE_KEY_PREFIX
,
backfill_lease
)
end
def
lease_key
...
...
app/workers/geo_backfill_worker.rb
View file @
99373c0d
...
...
@@ -12,14 +12,19 @@ class GeoBackfillWorker
logger
.
info
"Started Geo backfilling for
#{
project_ids
.
length
}
project(s)"
project_ids
.
each
do
|
project_id
|
break
if
Time
.
now
-
start
>=
RUN_TIME
break
unless
node_enabled?
project
=
Project
.
find
(
project_id
)
next
if
project
.
repository_exists?
try_obtain_lease
do
|
lease
|
GeoSingleRepositoryBackfillWorker
.
new
.
perform
(
project_id
,
lease
)
begin
break
if
Time
.
now
-
start
>=
RUN_TIME
break
unless
node_enabled?
project
=
Project
.
find
(
project_id
)
next
if
project
.
repository_exists?
try_obtain_lease
do
|
lease
|
GeoSingleRepositoryBackfillWorker
.
new
.
perform
(
project_id
,
lease
)
end
rescue
ActiveRecord
::
RecordNotFound
logger
.
error
(
"Couldn't find project with ID=
#{
project_id
}
, skipping syncing"
)
next
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