Merge branch 'zj-namespace-service-mandatory' into 'master'
Remove old GitLab Shell namespace actions implementations See merge request gitlab-org/gitlab-ce!18681
This commit is contained in:
commit
66ba430d7f
2 changed files with 9 additions and 40 deletions
5
changelogs/unreleased/zj-namespace-service-mandatory.yml
Normal file
5
changelogs/unreleased/zj-namespace-service-mandatory.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Finish NamespaceService migration to Gitaly
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: performance
|
|
@ -294,17 +294,7 @@ module Gitlab
|
||||||
# add_namespace("default", "gitlab")
|
# add_namespace("default", "gitlab")
|
||||||
#
|
#
|
||||||
def add_namespace(storage, name)
|
def add_namespace(storage, name)
|
||||||
Gitlab::GitalyClient.migrate(:add_namespace,
|
Gitlab::GitalyClient::NamespaceService.new(storage).add(name)
|
||||||
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
|
|
||||||
if enabled
|
|
||||||
Gitlab::GitalyClient::NamespaceService.new(storage).add(name)
|
|
||||||
else
|
|
||||||
path = full_path(storage, name)
|
|
||||||
FileUtils.mkdir_p(path, mode: 0770) unless exists?(storage, name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue Errno::EEXIST => e
|
|
||||||
Rails.logger.warn("Directory exists as a file: #{e} at: #{path}")
|
|
||||||
rescue GRPC::InvalidArgument => e
|
rescue GRPC::InvalidArgument => e
|
||||||
raise ArgumentError, e.message
|
raise ArgumentError, e.message
|
||||||
end
|
end
|
||||||
|
@ -316,14 +306,7 @@ module Gitlab
|
||||||
# rm_namespace("default", "gitlab")
|
# rm_namespace("default", "gitlab")
|
||||||
#
|
#
|
||||||
def rm_namespace(storage, name)
|
def rm_namespace(storage, name)
|
||||||
Gitlab::GitalyClient.migrate(:remove_namespace,
|
Gitlab::GitalyClient::NamespaceService.new(storage).remove(name)
|
||||||
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
|
|
||||||
if enabled
|
|
||||||
Gitlab::GitalyClient::NamespaceService.new(storage).remove(name)
|
|
||||||
else
|
|
||||||
FileUtils.rm_r(full_path(storage, name), force: true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue GRPC::InvalidArgument => e
|
rescue GRPC::InvalidArgument => e
|
||||||
raise ArgumentError, e.message
|
raise ArgumentError, e.message
|
||||||
end
|
end
|
||||||
|
@ -335,17 +318,7 @@ module Gitlab
|
||||||
# mv_namespace("/path/to/storage", "gitlab", "gitlabhq")
|
# mv_namespace("/path/to/storage", "gitlab", "gitlabhq")
|
||||||
#
|
#
|
||||||
def mv_namespace(storage, old_name, new_name)
|
def mv_namespace(storage, old_name, new_name)
|
||||||
Gitlab::GitalyClient.migrate(:rename_namespace,
|
Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name)
|
||||||
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
|
|
||||||
if enabled
|
|
||||||
Gitlab::GitalyClient::NamespaceService.new(storage)
|
|
||||||
.rename(old_name, new_name)
|
|
||||||
else
|
|
||||||
break false if exists?(storage, new_name) || !exists?(storage, old_name)
|
|
||||||
|
|
||||||
FileUtils.mv(full_path(storage, old_name), full_path(storage, new_name))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue GRPC::InvalidArgument
|
rescue GRPC::InvalidArgument
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -370,17 +343,8 @@ module Gitlab
|
||||||
# exists?(storage, 'gitlab')
|
# exists?(storage, 'gitlab')
|
||||||
# exists?(storage, 'gitlab/cookies.git')
|
# exists?(storage, 'gitlab/cookies.git')
|
||||||
#
|
#
|
||||||
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/385
|
|
||||||
def exists?(storage, dir_name)
|
def exists?(storage, dir_name)
|
||||||
Gitlab::GitalyClient.migrate(:namespace_exists,
|
Gitlab::GitalyClient::NamespaceService.new(storage).exists?(dir_name)
|
||||||
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |enabled|
|
|
||||||
if enabled
|
|
||||||
Gitlab::GitalyClient::NamespaceService.new(storage)
|
|
||||||
.exists?(dir_name)
|
|
||||||
else
|
|
||||||
File.exist?(full_path(storage, dir_name))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
Loading…
Reference in a new issue