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
2310f437
Commit
2310f437
authored
Sep 18, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a JWT header to synchronize the default branch
parent
a42f54a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
10 deletions
+37
-10
ee/app/services/geo/base_sync_service.rb
ee/app/services/geo/base_sync_service.rb
+11
-6
ee/app/services/geo/repository_sync_service.rb
ee/app/services/geo/repository_sync_service.rb
+4
-1
ee/changelogs/unreleased/7619-geo-fails-to-sync-with-gitaly-error-fatal-could-not-read-username.yml
...-sync-with-gitaly-error-fatal-could-not-read-username.yml
+5
-0
ee/spec/services/geo/repository_sync_service_spec.rb
ee/spec/services/geo/repository_sync_service_spec.rb
+17
-3
No files found.
ee/app/services/geo/base_sync_service.rb
View file @
2310f437
...
...
@@ -93,15 +93,20 @@ module Geo
end
def
fetch_geo_mirror
(
repository
)
url
=
Gitlab
::
Geo
.
primary_node
.
url
+
repository
.
full_path
+
'.git'
# Fetch the repository, using a JWT header for authentication
repository
.
with_config
(
jwt_authentication_header
)
do
repository
.
fetch_as_mirror
(
remote_url
,
remote_name:
GEO_REMOTE_NAME
,
forced:
true
)
end
end
# Build a JWT header for authentication
def
jwt_authentication_header
authorization
=
::
Gitlab
::
Geo
::
RepoSyncRequest
.
new
.
authorization
header
=
{
"http.
#{
url
}
.extraHeader"
=>
"Authorization:
#{
authorization
}
"
}
{
"http.
#{
remote_url
}
.extraHeader"
=>
"Authorization:
#{
authorization
}
"
}
end
repository
.
with_config
(
header
)
do
repository
.
fetch_as_mirror
(
url
,
remote_name:
GEO_REMOTE_NAME
,
forced:
true
)
end
def
remote_url
Gitlab
::
Geo
.
primary_node
.
url
+
repository
.
full_path
+
'.git'
end
# Use snapshotting for redownloads *only* when enabled.
...
...
ee/app/services/geo/repository_sync_service.rb
View file @
2310f437
...
...
@@ -46,7 +46,10 @@ module Geo
end
def
update_root_ref
project
.
update_root_ref
(
GEO_REMOTE_NAME
)
# Find the remote root ref, using a JWT header for authentication
repository
.
with_config
(
jwt_authentication_header
)
do
project
.
update_root_ref
(
GEO_REMOTE_NAME
)
end
end
def
schedule_repack
...
...
ee/changelogs/unreleased/7619-geo-fails-to-sync-with-gitaly-error-fatal-could-not-read-username.yml
0 → 100644
View file @
2310f437
---
title
:
Geo - Find the remote root ref using a JWT header for authentication
merge_request
:
7405
author
:
type
:
fixed
ee/spec/services/geo/repository_sync_service_spec.rb
View file @
2310f437
...
...
@@ -39,7 +39,11 @@ describe Geo::RepositorySyncService do
end
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
(
:with_config
)
.
with
(
"http.
#{
url_to_repo
}
.extraHeader"
=>
anything
)
.
twice
.
and_call_original
expect
(
repository
).
to
receive
(
:fetch_as_mirror
)
.
with
(
url_to_repo
,
remote_name:
'geo'
,
forced:
true
)
.
once
...
...
@@ -229,7 +233,12 @@ describe Geo::RepositorySyncService do
subject
.
execute
end
it
'updates the default branch'
do
it
'updates the default branch with JWT credentials'
do
expect
(
repository
).
to
receive
(
:with_config
)
.
with
(
"http.
#{
url_to_repo
}
.extraHeader"
=>
anything
)
.
twice
.
and_call_original
expect
(
project
).
to
receive
(
:change_head
).
with
(
'feature'
).
once
subject
.
execute
...
...
@@ -250,7 +259,12 @@ describe Geo::RepositorySyncService do
subject
.
execute
end
it
'does not update the default branch'
do
it
'updates the default branch with JWT credentials'
do
expect
(
repository
).
to
receive
(
:with_config
)
.
with
(
"http.
#{
url_to_repo
}
.extraHeader"
=>
anything
)
.
twice
.
and_call_original
expect
(
project
).
not_to
receive
(
:change_head
)
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