diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-13 12:57:19 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-25 13:36:22 +0200 |
commit | ec4423665cacfe2f0675fb8b9b5bd8dd17a77dd7 (patch) | |
tree | fe5a65b05aaf34f1aa40bdcea3c139ad6e7b91a4 /db/migrate | |
parent | cc0b4e3c7612f99a6acb20b9611a10a61fa7d687 (diff) | |
download | gitlab-ce-ec4423665cacfe2f0675fb8b9b5bd8dd17a77dd7.tar.gz |
Gitlab::Shell works on shard name, not path
Direct disk access is done through Gitaly now, so the legacy path was
deprecated. This path was used in Gitlab::Shell however. This required
the refactoring in this commit.
Added is the removal of direct path access on the project model, as that
lookup wasn't needed anymore is most cases.
Closes https://gitlab.com/gitlab-org/gitaly/issues/1111
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20161220141214_remove_dot_git_from_group_names.rb | 12 | ||||
-rw-r--r-- | db/migrate/20161226122833_remove_dot_git_from_usernames.rb | 22 |
2 files changed, 17 insertions, 17 deletions
diff --git a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb index bddc234db25..17357b67ab7 100644 --- a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb +++ b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb @@ -59,17 +59,17 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration end def move_namespace(group_id, path_was, path) - repository_storage_paths = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row| - Gitlab.config.repositories.storages[row['repository_storage']].legacy_disk_path + repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row| + row['repository_storage'] end.compact # Move the namespace directory in all storages paths used by member projects - repository_storage_paths.each do |repository_storage_path| + repository_storages.each do |repository_storage| # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage_path, path_was) + gitlab_shell.add_namespace(repository_storage, path_was) - unless gitlab_shell.mv_namespace(repository_storage_path, path_was, path) - Rails.logger.error "Exception moving path #{repository_storage_path} from #{path_was} to #{path}" + unless gitlab_shell.mv_namespace(repository_storage, path_was, path) + Rails.logger.error "Exception moving on shard #{repository_storage} from #{path_was} to #{path}" # if we cannot move namespace directory we should rollback # db changes in order to prevent out of sync between db and fs diff --git a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb index 7c28d934c29..8986cd8cb4b 100644 --- a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb +++ b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb @@ -53,8 +53,8 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration select_all("SELECT id, path FROM routes WHERE path = '#{quote_string(path)}'").present? end - def path_exists?(path, repository_storage_path) - repository_storage_path && gitlab_shell.exists?(repository_storage_path, path) + def path_exists?(shard, repository_storage_path) + repository_storage_path && gitlab_shell.exists?(shard, repository_storage_path) end # Accepts invalid path like test.git and returns test_git or @@ -70,8 +70,8 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration def check_routes(base, counter, path) route_exists = route_exists?(path) - Gitlab.config.repositories.storages.each_value do |storage| - if route_exists || path_exists?(path, storage.legacy_disk_path) + Gitlab.config.repositories.storages.each do |shard, storage| + if route_exists || path_exists?(shard, storage.legacy_disk_path) counter += 1 path = "#{base}#{counter}" @@ -83,17 +83,17 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration end def move_namespace(namespace_id, path_was, path) - repository_storage_paths = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row| - Gitlab.config.repositories.storages[row['repository_storage']].legacy_disk_path + repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row| + row['repository_storage'] end.compact - # Move the namespace directory in all storages paths used by member projects - repository_storage_paths.each do |repository_storage_path| + # Move the namespace directory in all storages used by member projects + repository_storages.each do |repository_storage| # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage_path, path_was) + gitlab_shell.add_namespace(repository_storage, path_was) - unless gitlab_shell.mv_namespace(repository_storage_path, path_was, path) - Rails.logger.error "Exception moving path #{repository_storage_path} from #{path_was} to #{path}" + unless gitlab_shell.mv_namespace(repository_storage, path_was, path) + Rails.logger.error "Exception moving on shard #{repository_storage} from #{path_was} to #{path}" # if we cannot move namespace directory we should rollback # db changes in order to prevent out of sync between db and fs |