diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /lib/tasks/gitlab/pages.rake | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/pages.rake')
-rw-r--r-- | lib/tasks/gitlab/pages.rake | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake new file mode 100644 index 00000000000..e15cbb4e32e --- /dev/null +++ b/lib/tasks/gitlab/pages.rake @@ -0,0 +1,35 @@ +require 'logger' + +namespace :gitlab do + namespace :pages do + desc "GitLab | Pages | Migrate legacy storage to zip format" + task migrate_legacy_storage: :gitlab_environment do + logger = Logger.new(STDOUT) + logger.info('Starting to migrate legacy pages storage to zip deployments') + processed_projects = 0 + + ProjectPagesMetadatum.only_on_legacy_storage.each_batch(of: 10) do |batch| + batch.preload(project: [:namespace, :route, pages_metadatum: :pages_deployment]).each do |metadatum| + project = metadatum.project + + result = nil + time = Benchmark.realtime do + result = ::Pages::MigrateLegacyStorageToDeploymentService.new(project).execute + end + processed_projects += 1 + + if result[:status] == :success + logger.info("project_id: #{project.id} #{project.pages_path} has been migrated in #{time} seconds") + else + logger.error("project_id: #{project.id} #{project.pages_path} failed to be migrated in #{time} seconds: #{result[:message]}") + end + rescue => e + logger.error("#{e.message} project_id: #{project&.id}") + Gitlab::ErrorTracking.track_exception(e, project_id: project&.id) + end + + logger.info("#{processed_projects} pages projects are processed") + end + end + end +end |