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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
8f50ef5e
Commit
8f50ef5e
authored
Mar 22, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate GRPC channels per repository storage
parent
c837da34
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
38 deletions
+36
-38
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
config/initializers/8_gitaly.rb
config/initializers/8_gitaly.rb
+3
-1
lib/api/internal.rb
lib/api/internal.rb
+1
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+13
-17
lib/gitlab/gitaly_client/commit.rb
lib/gitlab/gitaly_client/commit.rb
+4
-2
lib/gitlab/gitaly_client/notifications.rb
lib/gitlab/gitaly_client/notifications.rb
+10
-5
spec/lib/gitlab/gitaly_client/notifications_spec.rb
spec/lib/gitlab/gitaly_client/notifications_spec.rb
+2
-9
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+2
-2
No files found.
config/initializers/1_settings.rb
View file @
8f50ef5e
...
...
@@ -440,7 +440,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
# Gitaly
#
Settings
[
'gitaly'
]
||=
Settingslogic
.
new
({})
Settings
.
gitaly
[
'
socket_path'
]
||=
ENV
[
'GITALY_SOCKET_PATH'
]
Settings
.
gitaly
[
'
enabled'
]
||=
false
#
# Webpack settings
...
...
config/initializers/8_gitaly.rb
View file @
8f50ef5e
# Make sure we initialize a Gitaly channel before Sidekiq starts multi-threaded execution.
Gitlab
::
GitalyClient
.
channel
unless
Rails
.
env
.
test?
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
params
|
Gitlab
::
GitalyClient
.
configure_channel
(
name
,
params
[
'socket_path'
])
end
lib/api/internal.rb
View file @
8f50ef5e
...
...
@@ -139,7 +139,7 @@ module API
return
unless
Gitlab
::
GitalyClient
.
enabled?
begin
Gitlab
::
GitalyClient
::
Notifications
.
new
.
post_receive
(
params
[
:repo_path
])
Gitlab
::
GitalyClient
::
Notifications
.
new
(
params
[
:repo_path
]).
post_receive
rescue
GRPC
::
Unavailable
=>
e
render_api_error
(
e
,
500
)
end
...
...
lib/gitlab/gitaly_client.rb
View file @
8f50ef5e
...
...
@@ -4,28 +4,24 @@ module Gitlab
module
GitalyClient
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
def
self
.
gitaly_address
if
Gitlab
.
config
.
gitaly
.
socket_path
"unix://
#{
Gitlab
.
config
.
gitaly
.
socket_path
}
"
def
self
.
configure_channel
(
shard
,
socket_path
)
@channel
||=
{}
@channel
[
shard
]
=
new_channel
(
"unix://
#{
socket_path
}
"
)
end
end
def
self
.
channel
return
@channel
if
defined?
(
@channel
)
@channel
=
if
enabled?
def
self
.
new_channel
(
address
)
# NOTE: Gitaly currently runs on a Unix socket, so permissions are
# handled using the file system and no additional authentication is
# required (therefore the :this_channel_is_insecure flag)
GRPC
::
Core
::
Channel
.
new
(
gitaly_address
,
{},
:this_channel_is_insecure
)
else
nil
GRPC
::
Core
::
Channel
.
new
(
address
,
{},
:this_channel_is_insecure
)
end
def
self
.
get_channel
(
shard
)
@channel
.
fetch
(
shard
)
end
def
self
.
enabled?
gitaly_address
.
present?
Gitlab
.
config
.
gitaly
.
enabled
end
def
self
.
feature_enabled?
(
feature
)
...
...
lib/gitlab/gitaly_client/commit.rb
View file @
8f50ef5e
...
...
@@ -7,8 +7,10 @@ module Gitlab
class
<<
self
def
diff_from_parent
(
commit
,
options
=
{})
stub
=
Gitaly
::
Diff
::
Stub
.
new
(
nil
,
nil
,
channel_override:
GitalyClient
.
channel
)
repo
=
Gitaly
::
Repository
.
new
(
path:
commit
.
project
.
repository
.
path_to_repo
)
project
=
commit
.
project
channel
=
GitalyClient
.
get_channel
(
project
.
repository_storage
)
stub
=
Gitaly
::
Diff
::
Stub
.
new
(
nil
,
nil
,
channel_override:
channel
)
repo
=
Gitaly
::
Repository
.
new
(
path:
project
.
repository
.
path_to_repo
)
parent
=
commit
.
parents
[
0
]
parent_id
=
parent
?
parent
.
id
:
EMPTY_TREE_ID
request
=
Gitaly
::
CommitDiffRequest
.
new
(
...
...
lib/gitlab/gitaly_client/notifications.rb
View file @
8f50ef5e
...
...
@@ -3,14 +3,19 @@ module Gitlab
class
Notifications
attr_accessor
:stub
def
initialize
@stub
=
Gitaly
::
Notifications
::
Stub
.
new
(
nil
,
nil
,
channel_override:
GitalyClient
.
channel
)
def
initialize
(
repo_path
)
full_path
=
Gitlab
::
RepoPath
.
strip_storage_path
(
repo_path
).
sub
(
/\.git\z/
,
''
).
sub
(
/\.wiki\z/
,
''
)
@project
=
Project
.
find_by_full_path
(
full_path
)
channel
=
GitalyClient
.
get_channel
(
@project
.
repository_storage
)
@stub
=
Gitaly
::
Notifications
::
Stub
.
new
(
nil
,
nil
,
channel_override:
channel
)
end
def
post_receive
(
repo_path
)
repository
=
Gitaly
::
Repository
.
new
(
path:
repo_path
)
def
post_receive
repository
=
Gitaly
::
Repository
.
new
(
path:
@project
.
repository
.
path_to_repo
)
request
=
Gitaly
::
PostReceiveRequest
.
new
(
repository:
repository
)
stub
.
post_receive
(
request
)
@
stub
.
post_receive
(
request
)
end
end
end
...
...
spec/lib/gitlab/gitaly_client/notifications_spec.rb
View file @
8f50ef5e
require
'spec_helper'
describe
Gitlab
::
GitalyClient
::
Notifications
do
let
(
:client
)
{
Gitlab
::
GitalyClient
::
Notifications
.
new
}
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:socket_path
).
and_return
(
'path/to/gitaly.socket'
)
end
describe
'#post_receive'
do
let
(
:repo_path
)
{
'/path/to/my_repo.git'
}
it
'sends a post_receive message'
do
repo_path
=
create
(
:empty_project
).
repository
.
path_to_repo
expect_any_instance_of
(
Gitaly
::
Notifications
::
Stub
).
to
receive
(
:post_receive
).
with
(
post_receive_request_with_repo_path
(
repo_path
))
client
.
post_receive
(
repo_path
)
described_class
.
new
(
repo_path
).
post_receive
end
end
end
spec/requests/api/internal_spec.rb
View file @
8f50ef5e
...
...
@@ -429,7 +429,7 @@ describe API::Internal, api: true do
it
"calls the Gitaly client if it's enabled"
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
to
receive
(
:post_receive
)
.
with
(
project
.
repository
.
path
)
to
receive
(
:post_receive
)
post
api
(
"/internal/notify_post_receive"
),
valid_params
...
...
@@ -438,7 +438,7 @@ describe API::Internal, api: true do
it
"returns 500 if the gitaly call fails"
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Notifications
).
to
receive
(
:post_receive
).
with
(
project
.
repository
.
path
).
and_raise
(
GRPC
::
Unavailable
)
to
receive
(
:post_receive
).
and_raise
(
GRPC
::
Unavailable
)
post
api
(
"/internal/notify_post_receive"
),
valid_params
...
...
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