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
7e911edc
Commit
7e911edc
authored
Jun 20, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop passing around `redownload` unnecessarily
parent
e10c719d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
21 deletions
+22
-21
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+3
-3
ee/app/services/geo/base_sync_service.rb
ee/app/services/geo/base_sync_service.rb
+11
-8
ee/app/services/geo/repository_sync_service.rb
ee/app/services/geo/repository_sync_service.rb
+2
-3
ee/app/services/geo/wiki_sync_service.rb
ee/app/services/geo/wiki_sync_service.rb
+2
-3
ee/spec/services/geo/repository_sync_service_spec.rb
ee/spec/services/geo/repository_sync_service_spec.rb
+3
-3
ee/spec/support/services/base_sync_service_shared_examples.rb
...pec/support/services/base_sync_service_shared_examples.rb
+1
-1
No files found.
ee/app/models/geo/project_registry.rb
View file @
7e911edc
...
...
@@ -136,10 +136,10 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
set
(
fetches_since_gc_redis_key
,
value
)
}
end
def
should_be_re
tri
ed?
(
type
)
return
fals
e
if
public_send
(
"force_to_redownload_
#{
type
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
def
should_be_re
download
ed?
(
type
)
return
tru
e
if
public_send
(
"force_to_redownload_
#{
type
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
retry_count
(
type
)
<=
RETRIES_BEFORE_REDOWNLOAD
retry_count
(
type
)
>
RETRIES_BEFORE_REDOWNLOAD
end
private
...
...
ee/app/services/geo/base_sync_service.rb
View file @
7e911edc
...
...
@@ -25,11 +25,7 @@ module Geo
try_obtain_lease
do
log_info
(
"Started
#{
type
}
sync"
)
if
registry
.
should_be_retried?
(
type
)
sync_repository
else
sync_repository
(
true
)
end
sync_repository
log_info
(
"Finished
#{
type
}
sync"
)
end
...
...
@@ -45,7 +41,7 @@ module Geo
private
def
fetch_repository
(
redownload
)
def
fetch_repository
log_info
(
"Trying to fetch
#{
type
}
"
)
clean_up_temporary_repository
...
...
@@ -53,9 +49,8 @@ module Geo
registry
.
start_sync!
(
type
)
if
redownload
if
redownload
?
redownload_repository
set_temp_repository_as_main
schedule_repack
elsif
repository
.
exists?
fetch_geo_mirror
(
repository
)
...
...
@@ -66,6 +61,10 @@ module Geo
end
end
def
redownload?
registry
.
should_be_redownloaded?
(
type
)
end
def
schedule_repack
raise
NotImplementedError
end
...
...
@@ -83,6 +82,10 @@ module Geo
end
fetch_geo_mirror
(
temp_repo
)
set_temp_repository_as_main
ensure
clean_up_temporary_repository
end
def
current_node
...
...
ee/app/services/geo/repository_sync_service.rb
View file @
7e911edc
...
...
@@ -4,8 +4,8 @@ module Geo
private
def
sync_repository
(
redownload
=
false
)
fetch_repository
(
redownload
)
def
sync_repository
fetch_repository
update_gitattributes
...
...
@@ -27,7 +27,6 @@ module Geo
log_info
(
'Expiring caches'
)
project
.
repository
.
after_create
ensure
clean_up_temporary_repository
if
redownload
expire_repository_caches
execute_housekeeping
end
...
...
ee/app/services/geo/wiki_sync_service.rb
View file @
7e911edc
...
...
@@ -4,8 +4,8 @@ module Geo
private
def
sync_repository
(
redownload
=
false
)
fetch_repository
(
redownload
)
def
sync_repository
fetch_repository
mark_sync_as_successful
rescue
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
,
...
...
@@ -23,7 +23,6 @@ module Geo
log_info
(
'Setting force_to_redownload flag'
)
fail_registry!
(
'Invalid wiki'
,
e
,
force_to_redownload_wiki:
true
)
ensure
clean_up_temporary_repository
if
redownload
expire_repository_caches
end
...
...
ee/spec/services/geo/repository_sync_service_spec.rb
View file @
7e911edc
...
...
@@ -253,7 +253,7 @@ describe Geo::RepositorySyncService do
it
'tries to fetch repo'
do
create
(
:geo_project_registry
,
project:
project
,
repository_retry_count:
Geo
::
ProjectRegistry
::
RETRIES_BEFORE_REDOWNLOAD
-
1
)
expect
(
subject
).
to
receive
(
:sync_repository
)
.
with
(
no_args
)
expect
(
subject
).
to
receive
(
:sync_repository
)
subject
.
execute
end
...
...
@@ -269,7 +269,7 @@ describe Geo::RepositorySyncService do
it
'tries to redownload repo'
do
create
(
:geo_project_registry
,
project:
project
,
repository_retry_count:
Geo
::
ProjectRegistry
::
RETRIES_BEFORE_REDOWNLOAD
+
1
)
expect
(
subject
).
to
receive
(
:sync_repository
).
with
(
true
).
and_call_original
expect
(
subject
).
to
receive
(
:sync_repository
).
and_call_original
expect
(
subject
.
gitlab_shell
).
to
receive
(
:mv_repository
).
exactly
(
2
).
times
.
and_call_original
expect
(
subject
.
gitlab_shell
).
to
receive
(
:add_namespace
).
with
(
...
...
@@ -297,7 +297,7 @@ describe Geo::RepositorySyncService do
force_to_redownload_repository:
true
)
expect
(
subject
).
to
receive
(
:sync_repository
)
.
with
(
true
)
expect
(
subject
).
to
receive
(
:sync_repository
)
subject
.
execute
end
...
...
ee/spec/support/services/base_sync_service_shared_examples.rb
View file @
7e911edc
...
...
@@ -50,7 +50,7 @@ end
shared_examples
'geo base sync fetch and repack'
do
describe
'#fetch_repository'
do
let
(
:fetch_repository
)
{
subject
.
send
(
:fetch_repository
,
false
)
}
let
(
:fetch_repository
)
{
subject
.
send
(
:fetch_repository
)
}
before
do
allow
(
subject
).
to
receive
(
:fetch_geo_mirror
).
and_return
(
true
)
...
...
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