Commit a752c56c authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Deprecate legacy disk paths

Direct disk access is impossible on environments where components run in
their own container. There for constructing the path should not be done
except for exceptional cases.

One of the considerations, instead of logging, was to use Sentry. For
now I've chosen not to use this as the impact of this change is hard to
determine. Getting this in now will allow us to checkout the impact on
dev.gitlab.org and staging.
parent b2f57a56
deprecator = ActiveSupport::Deprecation.new('11.0', 'GitLab')
if Gitlab.inc_controlled? || Rails.env.development?
ActiveSupport::Deprecation.deprecate_methods(Gitlab::GitalyClient::StorageSettings, :legacy_disk_path, deprecator: deprecator)
end
...@@ -12,4 +12,12 @@ module Gitlab ...@@ -12,4 +12,12 @@ module Gitlab
def self.staging? def self.staging?
Gitlab.config.gitlab.url == 'https://staging.gitlab.com' Gitlab.config.gitlab.url == 'https://staging.gitlab.com'
end end
def self.dev?
Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
end
def self.inc_controlled?
dev? || staging? || com?
end
end end
...@@ -75,9 +75,6 @@ module Gitlab ...@@ -75,9 +75,6 @@ module Gitlab
end end
end end
# Full path to repo
attr_reader :path
# Directory name of repo # Directory name of repo
attr_reader :name attr_reader :name
...@@ -96,14 +93,13 @@ module Gitlab ...@@ -96,14 +93,13 @@ module Gitlab
@relative_path = relative_path @relative_path = relative_path
@gl_repository = gl_repository @gl_repository = gl_repository
storage_path = Gitlab.config.repositories.storages[@storage].legacy_disk_path
@gitlab_projects = Gitlab::Git::GitlabProjects.new( @gitlab_projects = Gitlab::Git::GitlabProjects.new(
storage, storage,
relative_path, relative_path,
global_hooks_path: Gitlab.config.gitlab_shell.hooks_path, global_hooks_path: Gitlab.config.gitlab_shell.hooks_path,
logger: Rails.logger logger: Rails.logger
) )
@path = File.join(storage_path, @relative_path)
@name = @relative_path.split("/").last @name = @relative_path.split("/").last
end end
...@@ -111,6 +107,12 @@ module Gitlab ...@@ -111,6 +107,12 @@ module Gitlab
path == other.path path == other.path
end end
def path
@path ||= File.join(
Gitlab.config.repositories.storages[@storage].legacy_disk_path, @relative_path
)
end
# Default branch in the repository # Default branch in the repository
def root_ref def root_ref
@root_ref ||= gitaly_migrate(:root_ref) do |is_enabled| @root_ref ||= gitaly_migrate(:root_ref) do |is_enabled|
...@@ -144,7 +146,7 @@ module Gitlab ...@@ -144,7 +146,7 @@ module Gitlab
gitaly_repository_client.exists? gitaly_repository_client.exists?
else else
circuit_breaker.perform do circuit_breaker.perform do
File.exist?(File.join(@path, 'refs')) File.exist?(File.join(path, 'refs'))
end end
end end
end end
...@@ -1000,7 +1002,7 @@ module Gitlab ...@@ -1000,7 +1002,7 @@ module Gitlab
if is_enabled if is_enabled
gitaly_repository_client.info_attributes gitaly_repository_client.info_attributes
else else
attributes_path = File.join(File.expand_path(@path), 'info', 'attributes') attributes_path = File.join(File.expand_path(path), 'info', 'attributes')
if File.exist?(attributes_path) if File.exist?(attributes_path)
File.read(attributes_path) File.read(attributes_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment