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
046ad504
Commit
046ad504
authored
Nov 08, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Add specs for error handling
parent
e9478858
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
6 deletions
+15
-6
app/models/geo/file_registry.rb
app/models/geo/file_registry.rb
+1
-1
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+9
-1
app/services/geo/base_sync_service.rb
app/services/geo/base_sync_service.rb
+3
-3
app/workers/concerns/delay.rb
app/workers/concerns/delay.rb
+1
-1
spec/support/services/base_sync_service_shared_examples.rb
spec/support/services/base_sync_service_shared_examples.rb
+1
-0
No files found.
app/models/geo/file_registry.rb
View file @
046ad504
class
Geo::FileRegistry
<
Geo
::
BaseRegistry
scope
:failed
,
->
{
where
(
success:
false
)
}
scope
:synced
,
->
{
where
(
success:
true
)
}
scope
:to_be_retried
,
->
{
where
(
'retry_at < ?'
,
Time
.
now
)
}
scope
:to_be_retried
,
->
{
where
(
'retry_at
is NULL OR retry_at
< ?'
,
Time
.
now
)
}
end
app/models/geo/project_registry.rb
View file @
046ad504
...
...
@@ -4,7 +4,6 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
validates
:project
,
presence:
true
,
uniqueness:
true
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
scope
:to_be_retried
,
->
{
where
(
arel_table
[
:repository_retry_at
].
lt
(
Time
.
now
).
or
(
arel_table
[
:wiki_retry_at
].
lt
(
Time
.
now
)))
}
def
self
.
failed
repository_sync_failed
=
arel_table
[
:last_repository_synced_at
].
not_eq
(
nil
)
...
...
@@ -16,6 +15,15 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
where
(
repository_sync_failed
.
or
(
wiki_sync_failed
))
end
def
self
.
to_be_retried
where
(
arel_table
[
:repository_retry_at
].
lt
(
Time
.
now
)
.
or
(
arel_table
[
:wiki_retry_at
].
lt
(
Time
.
now
))
.
or
(
arel_table
[
:wiki_retry_at
].
eq
(
nil
))
.
or
(
arel_table
[
:wiki_retry_at
].
eq
(
nil
))
)
end
def
self
.
synced
where
.
not
(
last_repository_synced_at:
nil
,
last_repository_successful_sync_at:
nil
)
.
where
(
resync_repository:
false
,
resync_wiki:
false
)
...
...
app/services/geo/base_sync_service.rb
View file @
046ad504
...
...
@@ -63,17 +63,17 @@ module Geo
private
def
retry_count
registry
.
public_send
(
"
#{
type
}
_retry_count"
)
||
0
registry
.
public_send
(
"
#{
type
}
_retry_count"
)
||
0
# rubocop:disable GitlabSecurity/PublicSend
end
def
should_be_retried?
return
false
if
registry
.
public_send
(
"force_to_redownload_
#{
type
}
"
)
return
false
if
registry
.
public_send
(
"force_to_redownload_
#{
type
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
retry_count
<=
RETRY_BEFORE_REDOWNLOAD
end
def
should_be_redownloaded?
return
true
if
registry
.
public_send
(
"force_to_redownload_
#{
type
}
"
)
return
true
if
registry
.
public_send
(
"force_to_redownload_
#{
type
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
(
RETRY_BEFORE_REDOWNLOAD
..
RETRY_LIMIT
)
===
retry_count
end
...
...
app/workers/concerns/delay.rb
View file @
046ad504
module
Delay
# Progressive backoff. It's copied from Sidekiq as is
def
delay
(
retry_count
=
0
)
(
retry_count
**
4
)
+
15
+
(
rand
(
30
)
*
(
retry_count
+
1
))
(
retry_count
**
4
)
+
15
+
(
rand
(
30
)
*
(
retry_count
+
1
))
end
end
spec/support/services/base_sync_service_shared_examples.rb
View file @
046ad504
...
...
@@ -8,6 +8,7 @@ shared_examples 'geo base sync execution' do
end
it
'executes the synchronization'
do
subject
.
class
.
type
||=
:wiki
expect
(
subject
).
to
receive
(
:sync_repository
)
subject
.
execute
...
...
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