Commit 92290ece authored by Vladimir Shushlin's avatar Vladimir Shushlin

Separatelly report migrated and failed projects

parent 09210823
...@@ -6,7 +6,8 @@ namespace :gitlab do ...@@ -6,7 +6,8 @@ namespace :gitlab do
task migrate_legacy_storage: :gitlab_environment do task migrate_legacy_storage: :gitlab_environment do
logger = Logger.new(STDOUT) logger = Logger.new(STDOUT)
logger.info('Starting to migrate legacy pages storage to zip deployments') logger.info('Starting to migrate legacy pages storage to zip deployments')
processed_projects = 0 projects_migrated = 0
projects_errored = 0
ProjectPagesMetadatum.only_on_legacy_storage.each_batch(of: 10) do |batch| ProjectPagesMetadatum.only_on_legacy_storage.each_batch(of: 10) do |batch|
batch.preload(project: [:namespace, :route, pages_metadatum: :pages_deployment]).each do |metadatum| batch.preload(project: [:namespace, :route, pages_metadatum: :pages_deployment]).each do |metadatum|
...@@ -16,20 +17,26 @@ namespace :gitlab do ...@@ -16,20 +17,26 @@ namespace :gitlab do
time = Benchmark.realtime do time = Benchmark.realtime do
result = ::Pages::MigrateLegacyStorageToDeploymentService.new(project).execute result = ::Pages::MigrateLegacyStorageToDeploymentService.new(project).execute
end end
processed_projects += 1
if result[:status] == :success if result[:status] == :success
logger.info("project_id: #{project.id} #{project.pages_path} has been migrated in #{time} seconds") logger.info("project_id: #{project.id} #{project.pages_path} has been migrated in #{time} seconds")
projects_migrated += 1
else else
logger.error("project_id: #{project.id} #{project.pages_path} failed to be migrated in #{time} seconds: #{result[:message]}") logger.error("project_id: #{project.id} #{project.pages_path} failed to be migrated in #{time} seconds: #{result[:message]}")
projects_errored += 1
end end
rescue => e rescue => e
projects_errored += 1
logger.error("#{e.message} project_id: #{project&.id}") logger.error("#{e.message} project_id: #{project&.id}")
Gitlab::ErrorTracking.track_exception(e, project_id: project&.id) Gitlab::ErrorTracking.track_exception(e, project_id: project&.id)
end end
logger.info("#{processed_projects} pages projects are processed") logger.info("#{projects_migrated} projects are migrated successfully, #{projects_errored} projects failed to be migrated")
end end
logger.info("A total of #{projects_migrated + projects_errored} projects were processed.")
logger.info("- The #{projects_migrated} projects migrated successfully")
logger.info("- The #{projects_errored} projects failed to be migrated")
end end
end end
end end
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