Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-04-12 10:12:21 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-04-12 16:23:36 +0300
commita752c56ca82d6f0fdee340f5d494347a4aa90072 (patch)
tree721698bb52f983d58031cd510732546a323d4e71
parentb2f57a561f0540f8e33c2d580252e6f95e9cf182 (diff)
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.
-rw-r--r--config/initializers/deprecations.rb5
-rw-r--r--lib/gitlab.rb8
-rw-r--r--lib/gitlab/git/repository.rb18
3 files changed, 23 insertions, 8 deletions
diff --git a/config/initializers/deprecations.rb b/config/initializers/deprecations.rb
new file mode 100644
index 00000000000..add744accee
--- /dev/null
+++ b/config/initializers/deprecations.rb
@@ -0,0 +1,5 @@
+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
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index aa9fd36d9ff..37ce01925bb 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -12,4 +12,12 @@ module Gitlab
def self.staging?
Gitlab.config.gitlab.url == 'https://staging.gitlab.com'
end
+
+ def self.dev?
+ Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
+ end
+
+ def self.inc_controlled?
+ dev? || staging? || com?
+ end
end
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 1a0a793564e..56a56949d3e 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -75,9 +75,6 @@ module Gitlab
end
end
- # Full path to repo
- attr_reader :path
-
# Directory name of repo
attr_reader :name
@@ -96,14 +93,13 @@ module Gitlab
@relative_path = relative_path
@gl_repository = gl_repository
- storage_path = Gitlab.config.repositories.storages[@storage].legacy_disk_path
@gitlab_projects = Gitlab::Git::GitlabProjects.new(
storage,
relative_path,
global_hooks_path: Gitlab.config.gitlab_shell.hooks_path,
logger: Rails.logger
)
- @path = File.join(storage_path, @relative_path)
+
@name = @relative_path.split("/").last
end
@@ -111,6 +107,12 @@ module Gitlab
path == other.path
end
+ def path
+ @path ||= File.join(
+ Gitlab.config.repositories.storages[@storage].legacy_disk_path, @relative_path
+ )
+ end
+
# Default branch in the repository
def root_ref
@root_ref ||= gitaly_migrate(:root_ref) do |is_enabled|
@@ -139,12 +141,12 @@ module Gitlab
end
def exists?
- Gitlab::GitalyClient.migrate(:repository_exists, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
+ Gitlab::GitalyClient.migrate(:repository_exists, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
if enabled
gitaly_repository_client.exists?
else
circuit_breaker.perform do
- File.exist?(File.join(@path, 'refs'))
+ File.exist?(File.join(path, 'refs'))
end
end
end
@@ -1000,7 +1002,7 @@ module Gitlab
if is_enabled
gitaly_repository_client.info_attributes
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)
File.read(attributes_path)