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

Remove direct disk access in RemoveDotGitFromUsernames

Prior to this change, the migration touched the disk path. This has been
removed.

Further, I believe it also fixes a bug. It seems that GitLab Shell
checks if the root path exists, when the path is duplicated. For
example, if the shard is located at /home/git, it did check if
`/home/git/home/git` existed.
parent cfbb256b
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class RemoveDotGitFromUsernames < ActiveRecord::Migration class RemoveDotGitFromUsernames < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
# Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
def up def up
...@@ -64,16 +60,14 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration ...@@ -64,16 +60,14 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration
# we rename suffix instead of removing it # we rename suffix instead of removing it
path = path.sub(/\.git\z/, '_git') path = path.sub(/\.git\z/, '_git')
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
check_routes(path.dup, 0, path) check_routes(path.dup, 0, path)
end end
end
def check_routes(base, counter, path) def check_routes(base, counter, path)
route_exists = route_exists?(path) route_exists = route_exists?(path)
Gitlab.config.repositories.storages.each do |shard, storage| Gitlab.config.repositories.storages.each do |shard, _storage|
if route_exists || path_exists?(shard, storage.legacy_disk_path) if route_exists || path_exists?(shard, path)
counter += 1 counter += 1
path = "#{base}#{counter}" path = "#{base}#{counter}"
......
...@@ -27,7 +27,7 @@ describe MigrateProcessCommitWorkerJobs do ...@@ -27,7 +27,7 @@ describe MigrateProcessCommitWorkerJobs do
end end
describe '#repository' do describe '#repository' do
it 'returns a Rugged::Repository' do it 'returns a mock implemention of ::Repository' do
migration_project = described_class::Project migration_project = described_class::Project
.find_including_path(project.id) .find_including_path(project.id)
...@@ -83,11 +83,7 @@ describe MigrateProcessCommitWorkerJobs do ...@@ -83,11 +83,7 @@ describe MigrateProcessCommitWorkerJobs do
end end
it 'encodes data to UTF-8' do it 'encodes data to UTF-8' do
allow_any_instance_of(Rugged::Repository).to receive(:lookup) allow(commit).to receive(:body)
.with(commit.id)
.and_return(commit)
allow(commit).to receive(:message)
.and_return('김치'.force_encoding('BINARY')) .and_return('김치'.force_encoding('BINARY'))
migration.up migration.up
......
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