Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
4c9555470029
Commit
4e3de96e
authored
Apr 05, 2017
by
Rémy Coutable
Browse files
Merge branch 'gitaly-prevent-autoload' into 'master'
Deal with Rails autoload instance variable resets See merge request !10338
parents
aefba3c067d5
147e7e04d80f
Changes
2
Hide whitespace changes
Inline
Side-by-side
config/initializers/8_gitaly.rb
View file @
4c955547
...
...
@@ -2,17 +2,5 @@
# 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
.
in?
(
%w(tcp unix)
)
raise
"Unsupported Gitaly address:
#{
address
.
inspect
}
"
end
Gitlab
::
GitalyClient
.
configure_channel
(
name
,
address
)
end
Gitlab
::
GitalyClient
.
configure_channels
end
lib/gitlab/gitaly_client.rb
View file @
4c955547
...
...
@@ -4,11 +4,23 @@ module Gitlab
module
GitalyClient
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
def
self
.
configure_channel
(
storage
,
address
)
@addresses
||=
{}
@addresses
[
storage
]
=
address
@channels
||=
{}
@channels
[
storage
]
=
new_channel
(
address
)
# This function is not thread-safe because it updates Hashes in instance variables.
def
self
.
configure_channels
@addresses
=
{}
@channels
=
{}
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
.
in?
(
%w(tcp unix)
)
raise
"Unsupported Gitaly address:
#{
address
.
inspect
}
"
end
@addresses
[
name
]
=
address
@channels
[
name
]
=
new_channel
(
address
)
end
end
def
self
.
new_channel
(
address
)
...
...
@@ -21,10 +33,26 @@ def self.new_channel(address)
end
def
self
.
get_channel
(
storage
)
if
!
Rails
.
env
.
production?
&&
@channels
.
nil?
# In development mode the Rails auto-loader may reset the instance
# variables of this class. What we do here is not thread-safe. In normal
# circumstances (including production) these instance variables have
# been initialized from config/initializers.
configure_channels
end
@channels
[
storage
]
end
def
self
.
get_address
(
storage
)
if
!
Rails
.
env
.
production?
&&
@addresses
.
nil?
# In development mode the Rails auto-loader may reset the instance
# variables of this class. What we do here is not thread-safe. In normal
# circumstances (including development) these instance variables have
# been initialized from config/initializers.
configure_channels
end
@addresses
[
storage
]
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