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
8b36ff2b
Commit
8b36ff2b
authored
Jan 25, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a fixed remote name for Geo mirrors
parent
d3061333
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
14 deletions
+46
-14
changelogs/unreleased-ee/4693-use-fixed-remote-name-for-geo.yml
...logs/unreleased-ee/4693-use-fixed-remote-name-for-geo.yml
+5
-0
ee/app/services/geo/base_sync_service.rb
ee/app/services/geo/base_sync_service.rb
+4
-1
spec/ee/spec/services/geo/repository_sync_service_spec.rb
spec/ee/spec/services/geo/repository_sync_service_spec.rb
+20
-7
spec/ee/spec/services/geo/wiki_sync_service_spec.rb
spec/ee/spec/services/geo/wiki_sync_service_spec.rb
+17
-6
No files found.
changelogs/unreleased-ee/4693-use-fixed-remote-name-for-geo.yml
0 → 100644
View file @
8b36ff2b
---
title
:
Use a fixed remote name for Geo mirrors
merge_request
:
4249
author
:
type
:
fixed
ee/app/services/geo/base_sync_service.rb
View file @
8b36ff2b
...
...
@@ -13,6 +13,7 @@ module Geo
attr_reader
:project
GEO_REMOTE_NAME
=
'geo'
.
freeze
LEASE_TIMEOUT
=
8
.
hours
.
freeze
LEASE_KEY_PREFIX
=
'geo_sync_service'
.
freeze
RETRY_BEFORE_REDOWNLOAD
=
5
...
...
@@ -82,7 +83,9 @@ module Geo
authorization
=
::
Gitlab
::
Geo
::
BaseRequest
.
new
.
authorization
header
=
{
"http.
#{
url
}
.extraHeader"
=>
"Authorization:
#{
authorization
}
"
}
repository
.
with_config
(
header
)
{
repository
.
fetch_as_mirror
(
url
,
forced:
true
)
}
repository
.
with_config
(
header
)
do
repository
.
fetch_as_mirror
(
url
,
remote_name:
GEO_REMOTE_NAME
,
forced:
true
)
end
end
def
registry
...
...
spec/ee/spec/services/geo/repository_sync_service_spec.rb
View file @
8b36ff2b
...
...
@@ -32,7 +32,9 @@ describe Geo::RepositorySyncService do
it
'fetches project repository with JWT credentials'
do
expect
(
repository
).
to
receive
(
:with_config
).
with
(
"http.
#{
url_to_repo
}
.extraHeader"
=>
anything
).
and_call_original
expect
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
).
once
expect
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
once
subject
.
execute
end
...
...
@@ -59,7 +61,9 @@ describe Geo::RepositorySyncService do
end
it
'returns the lease when sync fail'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Shell
::
Error
)
expect
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:cancel
).
once
.
with
(
subject
.
__send__
(
:lease_key
),
anything
).
and_call_original
...
...
@@ -76,20 +80,25 @@ describe Geo::RepositorySyncService do
end
it
'rescues when Gitlab::Shell::Error is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Shell
::
Error
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues when Gitlab::Git::RepositoryMirroring::RemoteError is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
(
repository
).
to
receive
(
:after_create
)
...
...
@@ -97,7 +106,9 @@ describe Geo::RepositorySyncService do
end
it
'increases retry count when Gitlab::Git::Repository::NoRepository is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
subject
.
execute
...
...
@@ -161,7 +172,9 @@ describe Geo::RepositorySyncService do
let
(
:registry
)
{
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
}
before
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
,
'shell error'
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Shell
::
Error
.
new
(
'shell error'
))
subject
.
execute
end
...
...
spec/ee/spec/services/geo/wiki_sync_service_spec.rb
View file @
8b36ff2b
...
...
@@ -32,7 +32,9 @@ RSpec.describe Geo::WikiSyncService do
it
'fetches wiki repository with JWT credentials'
do
expect
(
repository
).
to
receive
(
:with_config
).
with
(
"http.
#{
url_to_repo
}
.extraHeader"
=>
anything
).
and_call_original
expect
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
).
once
expect
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
once
subject
.
execute
end
...
...
@@ -59,26 +61,33 @@ RSpec.describe Geo::WikiSyncService do
end
it
'rescues exception when Gitlab::Shell::Error is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Shell
::
Error
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues exception when Gitlab::Git::RepositoryMirroring::RemoteError is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
RepositoryMirroring
::
RemoteError
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues exception when Gitlab::Git::Repository::NoRepository is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'increases retry count when Gitlab::Git::Repository::NoRepository is raised'
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
subject
.
execute
...
...
@@ -123,7 +132,9 @@ RSpec.describe Geo::WikiSyncService do
let
(
:registry
)
{
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
}
before
do
allow
(
repository
).
to
receive
(
:fetch_as_mirror
).
with
(
url_to_repo
,
forced:
true
)
{
raise
Gitlab
::
Shell
::
Error
,
'shell error'
}
allow
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
and_raise
(
Gitlab
::
Shell
::
Error
.
new
(
'shell error'
))
subject
.
execute
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