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:
authorJacob Vosmaer <jacob@gitlab.com>2018-06-05 18:58:28 +0300
committerJacob Vosmaer <jacob@gitlab.com>2018-06-12 15:33:37 +0300
commitf376347f24f24efc157d80de63381dd22d060630 (patch)
tree73dc59fbab206b2c5e79e6144b4d02c931da92a0 /lib/gitlab/shell.rb
parentb2ef7f6cd9b98681aeb2274e29f0b3aaac423fc9 (diff)
Find and mark more Git disk access locations, part 2
Diffstat (limited to 'lib/gitlab/shell.rb')
-rw-r--r--lib/gitlab/shell.rb59
1 files changed, 54 insertions, 5 deletions
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index 4a691d640b3..4b8aae4f5a2 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -106,10 +106,17 @@ module Gitlab
raise Error.new("don't use disk paths with import_repository: #{url.inspect}")
end
- # The timeout ensures the subprocess won't hang forever
- cmd = gitlab_projects(storage, "#{name}.git")
- success = cmd.import_project(url, git_timeout)
+ relative_path = "#{name}.git"
+ cmd = gitaly_migrate(:import_repository, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
+ if is_enabled
+ GitalyGitlabProjects.new(storage, relative_path)
+ else
+ # The timeout ensures the subprocess won't hang forever
+ gitlab_projects(storage, relative_path)
+ end
+ end
+ success = cmd.import_project(url, git_timeout)
raise Error, cmd.output unless success
success
@@ -165,8 +172,16 @@ module Gitlab
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/817
def fork_repository(forked_from_storage, forked_from_disk_path, forked_to_storage, forked_to_disk_path)
- gitlab_projects(forked_from_storage, "#{forked_from_disk_path}.git")
- .fork_repository(forked_to_storage, "#{forked_to_disk_path}.git")
+ forked_from_relative_path = "#{forked_from_disk_path}.git"
+ fork_args = [forked_to_storage, "#{forked_to_disk_path}.git"]
+
+ gitaly_migrate(:fork_repository, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
+ if is_enabled
+ GitalyGitlabProjects.new(forked_from_storage, forked_from_relative_path).fork_repository(*fork_args)
+ else
+ gitlab_projects(forked_from_storage, forked_from_relative_path).fork_repository(*fork_args)
+ end
+ end
end
# Removes a repository from file system, using rm_diretory which is an alias
@@ -452,5 +467,39 @@ module Gitlab
# need to do the same here...
raise Error, e
end
+
+ class GitalyGitlabProjects
+ attr_reader :shard_name, :repository_relative_path, :output
+
+ def initialize(shard_name, repository_relative_path)
+ @shard_name = shard_name
+ @repository_relative_path = repository_relative_path
+ @output = ''
+ end
+
+ def import_project(source, _timeout)
+ raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil)
+
+ Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source)
+ true
+ rescue GRPC::BadStatus => e
+ @output = e.message
+ false
+ end
+
+ def fork_repository(new_shard_name, new_repository_relative_path)
+ target_repository = Gitlab::Git::Repository.new(new_shard_name, new_repository_relative_path, nil)
+ raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil)
+
+ Gitlab::GitalyClient::RepositoryService.new(target_repository).fork_repository(raw_repository)
+ rescue GRPC::BadStatus => e
+ logger.error "fork-repository failed: #{e.message}"
+ false
+ end
+
+ def logger
+ Rails.logger
+ end
+ end
end
end