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
Jérome Perrin
gitlab-ce
Commits
1904c80f
Commit
1904c80f
authored
Mar 24, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change socket_path to gitaly_address
parent
eee07f1c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
31 deletions
+48
-31
config/gitlab.yml.example
config/gitlab.yml.example
+8
-8
config/initializers/8_gitaly.rb
config/initializers/8_gitaly.rb
+17
-3
doc/install/installation.md
doc/install/installation.md
+2
-2
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+11
-5
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+5
-4
spec/lib/gitlab/workhorse_spec.rb
spec/lib/gitlab/workhorse_spec.rb
+4
-8
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+1
-1
No files found.
config/gitlab.yml.example
View file @
1904c80f
...
@@ -443,14 +443,10 @@ production: &base
...
@@ -443,14 +443,10 @@ production: &base
# Gitaly settings
# Gitaly settings
gitaly:
gitaly:
# The socket_path setting is optional and obsolete. When this is set
# This setting controls whether GitLab uses Gitaly (new component
# GitLab assumes it can reach a Gitaly services via a Unix socket at
# introduced in 9.0). Eventually Gitaly use will become mandatory and
# this path. When this is commented out GitLab will not use Gitaly.
# this option will disappear.
#
enabled: false
# This setting is obsolete because we expect it to be moved under
# repositories/storages in GitLab 9.1.
#
# socket_path: tmp/sockets/private/gitaly.socket
#
#
# 4. Advanced settings
# 4. Advanced settings
...
@@ -465,6 +461,7 @@ production: &base
...
@@ -465,6 +461,7 @@ production: &base
storages: # You must have at least a `default` storage path.
storages: # You must have at least a `default` storage path.
default:
default:
path: /home/git/repositories/
path: /home/git/repositories/
gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket
## Backup settings
## Backup settings
backup:
backup:
...
@@ -577,6 +574,9 @@ test:
...
@@ -577,6 +574,9 @@ test:
storages:
storages:
default:
default:
path: tmp/tests/repositories/
path: tmp/tests/repositories/
gitaly_address: unix:<%= Rails.root.join('tmp/sockets/private/gitaly.socket') %>
gitaly:
enabled: false
backup:
backup:
path: tmp/tests/backups
path: tmp/tests/backups
gitlab_shell:
gitlab_shell:
...
...
config/initializers/8_gitaly.rb
View file @
1904c80f
# Make sure we initialize a Gitaly channel before Sidekiq starts multi-threaded execution.
require
'uri'
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
params
|
Gitlab
::
GitalyClient
.
configure_channel
(
name
,
params
[
'socket_path'
])
# Make sure we initialize our Gitaly channels before Sidekiq starts multi-threaded execution.
if
Gitlab
.
config
.
gitaly
.
enabled
||
Rails
.
env
.
test?
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
params
|
address
=
params
[
'gitaly_address'
]
unless
address
.
present?
raise
"storage
#{
name
.
inspect
}
is missing a gitaly_address"
end
unless
URI
(
address
).
scheme
==
'unix'
raise
"Unsupported Gitaly address:
#{
address
.
inspect
}
"
end
Gitlab
::
GitalyClient
.
configure_channel
(
name
,
address
)
end
end
end
doc/install/installation.md
View file @
1904c80f
...
@@ -477,12 +477,12 @@ with setting up Gitaly until you upgrade to GitLab 9.1 or later.
...
@@ -477,12 +477,12 @@ with setting up Gitaly until you upgrade to GitLab 9.1 or later.
# Enable Gitaly in the init script
# Enable Gitaly in the init script
echo 'gitaly_enabled=true' | sudo tee -a /etc/default/gitlab
echo 'gitaly_enabled=true' | sudo tee -a /etc/default/gitlab
Next, edit
`/home/git/gitlab/config/gitlab.yml`
and make sure
`
socket_path
`
in
Next, edit
`/home/git/gitlab/config/gitlab.yml`
and make sure
`
enabled: true
`
in
the
`gitaly:`
section is uncommented.
the
`gitaly:`
section is uncommented.
# <- gitlab.yml indentation starts here
# <- gitlab.yml indentation starts here
gitaly:
gitaly:
socket_path: tmp/sockets/private/gitaly.socket
enabled: true
For more information about configuring Gitaly see
For more information about configuring Gitaly see
[
doc/administration/gitaly
](
../administration/gitaly
)
.
[
doc/administration/gitaly
](
../administration/gitaly
)
.
...
...
lib/gitlab/gitaly_client.rb
View file @
1904c80f
...
@@ -4,9 +4,11 @@ module Gitlab
...
@@ -4,9 +4,11 @@ module Gitlab
module
GitalyClient
module
GitalyClient
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
def
self
.
configure_channel
(
shard
,
socket_path
)
def
self
.
configure_channel
(
storage
,
address
)
@channel
||=
{}
@addresses
||=
{}
@channel
[
shard
]
=
new_channel
(
"unix://
#{
socket_path
}
"
)
@addresses
[
storage
]
=
address
@channels
||=
{}
@channels
[
storage
]
=
new_channel
(
address
)
end
end
def
self
.
new_channel
(
address
)
def
self
.
new_channel
(
address
)
...
@@ -16,8 +18,12 @@ module Gitlab
...
@@ -16,8 +18,12 @@ module Gitlab
GRPC
::
Core
::
Channel
.
new
(
address
,
{},
:this_channel_is_insecure
)
GRPC
::
Core
::
Channel
.
new
(
address
,
{},
:this_channel_is_insecure
)
end
end
def
self
.
get_channel
(
shard
)
def
self
.
get_channel
(
storage
)
@channel
.
fetch
(
shard
)
@channels
[
storage
]
end
def
self
.
get_address
(
storage
)
@addresses
[
storage
]
end
end
def
self
.
enabled?
def
self
.
enabled?
...
...
lib/gitlab/workhorse.rb
View file @
1904c80f
require
'base64'
require
'base64'
require
'json'
require
'json'
require
'securerandom'
require
'securerandom'
require
'uri'
module
Gitlab
module
Gitlab
class
Workhorse
class
Workhorse
...
@@ -21,10 +22,10 @@ module Gitlab
...
@@ -21,10 +22,10 @@ module Gitlab
RepoPath
:
repository
.
path_to_repo
,
RepoPath
:
repository
.
path_to_repo
,
}
}
params
.
merge!
(
if
Gitlab
.
config
.
gitaly
.
enabled
GitalySocketPath
:
Gitlab
.
config
.
gitaly
.
socket_path
,
address
=
Gitlab
::
GitalyClient
.
get_address
(
repository
.
project
.
repository_storage
)
GitalyResourcePath
:
"/projects/
#{
repository
.
project
.
id
}
/git-http/info-refs"
,
params
[
:GitalySocketPath
]
=
URI
(
address
).
path
)
if
Gitlab
.
config
.
gitaly
.
socket_path
.
present?
end
params
params
end
end
...
...
spec/lib/gitlab/workhorse_spec.rb
View file @
1904c80f
...
@@ -184,18 +184,14 @@ describe Gitlab::Workhorse, lib: true do
...
@@ -184,18 +184,14 @@ describe Gitlab::Workhorse, lib: true do
it
{
expect
(
subject
).
to
eq
({
GL_ID
:
"user-
#{
user
.
id
}
"
,
RepoPath
:
repository
.
path_to_repo
})
}
it
{
expect
(
subject
).
to
eq
({
GL_ID
:
"user-
#{
user
.
id
}
"
,
RepoPath
:
repository
.
path_to_repo
})
}
context
'when Gitaly socket path is present'
do
context
'when Gitaly is enabled'
do
let
(
:gitaly_socket_path
)
{
'/tmp/gitaly.sock'
}
before
do
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:
socket_path
).
and_return
(
gitaly_socket_path
)
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:
enabled
).
and_return
(
true
)
end
end
it
'includes Gitaly params in the returned value'
do
it
'includes Gitaly params in the returned value'
do
expect
(
subject
).
to
include
({
gitaly_socket_path
=
URI
(
Gitlab
::
GitalyClient
.
get_address
(
'default'
)).
path
GitalyResourcePath
:
"/projects/
#{
repository
.
project
.
id
}
/git-http/info-refs"
,
expect
(
subject
).
to
include
({
GitalySocketPath
:
gitaly_socket_path
})
GitalySocketPath
:
gitaly_socket_path
,
})
end
end
end
end
end
end
...
...
spec/requests/api/internal_spec.rb
View file @
1904c80f
...
@@ -424,7 +424,7 @@ describe API::Internal, api: true do
...
@@ -424,7 +424,7 @@ describe API::Internal, api: true do
end
end
before
do
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:
socket_path
).
and_return
(
'path/to/gitaly.socket'
)
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:
enabled
).
and_return
(
true
)
end
end
it
"calls the Gitaly client if it's enabled"
do
it
"calls the Gitaly client if it's enabled"
do
...
...
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