2018-03-17 18:26:18 +05:30
|
|
|
namespace :gitlab do
|
|
|
|
namespace :storage do
|
|
|
|
desc 'GitLab | Storage | Migrate existing projects to Hashed Storage'
|
|
|
|
task migrate_to_hashed: :environment do
|
2019-02-15 15:39:39 +05:30
|
|
|
if Gitlab::Database.read_only?
|
|
|
|
warn 'This task requires database write access. Exiting.'
|
|
|
|
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
storage_migrator = Gitlab::HashedStorage::Migrator.new
|
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
|
|
|
|
if helper.range_single_item?
|
|
|
|
project = Project.with_unmigrated_storage.find_by(id: helper.range_from)
|
|
|
|
|
|
|
|
unless project
|
2019-02-15 15:39:39 +05:30
|
|
|
warn "There are no projects requiring storage migration with ID=#{helper.range_from}"
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Enqueueing storage migration of #{project.full_path} (ID=#{project.id})..."
|
|
|
|
storage_migrator.migrate(project)
|
|
|
|
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
legacy_projects_count = Project.with_unmigrated_storage.count
|
|
|
|
|
|
|
|
if legacy_projects_count == 0
|
2019-02-15 15:39:39 +05:30
|
|
|
warn 'There are no projects requiring storage migration. Nothing to do!'
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
print "Enqueuing migration of #{legacy_projects_count} projects in batches of #{helper.batch_size}"
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
helper.project_id_batches do |start, finish|
|
2019-03-02 22:35:43 +05:30
|
|
|
storage_migrator.bulk_schedule(start: start, finish: finish)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
print '.'
|
|
|
|
end
|
|
|
|
|
|
|
|
puts ' Done!'
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | Summary of existing projects using Legacy Storage'
|
|
|
|
task legacy_projects: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.relation_summary('projects using Legacy Storage', Project.without_storage_feature(:repository))
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | List existing projects using Legacy Storage'
|
|
|
|
task list_legacy_projects: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.projects_list('projects using Legacy Storage', Project.without_storage_feature(:repository))
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | Summary of existing projects using Hashed Storage'
|
|
|
|
task hashed_projects: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.relation_summary('projects using Hashed Storage', Project.with_storage_feature(:repository))
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | List existing projects using Hashed Storage'
|
|
|
|
task list_hashed_projects: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.projects_list('projects using Hashed Storage', Project.with_storage_feature(:repository))
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | Summary of project attachments using Legacy Storage'
|
|
|
|
task legacy_attachments: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.relation_summary('attachments using Legacy Storage', helper.legacy_attachments_relation)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | List existing project attachments using Legacy Storage'
|
|
|
|
task list_legacy_attachments: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.attachments_list('attachments using Legacy Storage', helper.legacy_attachments_relation)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | Summary of project attachments using Hashed Storage'
|
|
|
|
task hashed_attachments: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.relation_summary('attachments using Hashed Storage', helper.hashed_attachments_relation)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Gitlab | Storage | List existing project attachments using Hashed Storage'
|
|
|
|
task list_hashed_attachments: :environment do
|
2018-11-08 19:23:39 +05:30
|
|
|
helper = Gitlab::HashedStorage::RakeHelper
|
|
|
|
helper.attachments_list('attachments using Hashed Storage', helper.hashed_attachments_relation)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|