From 6e06d5eac362a5ec31bbb99170ba841bb3275c71 Mon Sep 17 00:00:00 2001 From: Tian Chen Date: Fri, 21 Jul 2023 09:26:28 +0800 Subject: [PATCH] List the names of failed batches --- notifier/background_migration.rb | 10 ++++++++-- .../fixtures/migration-testing/v4/expected-comment.txt | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/notifier/background_migration.rb b/notifier/background_migration.rb index 43361f3c..673785d5 100644 --- a/notifier/background_migration.rb +++ b/notifier/background_migration.rb @@ -75,7 +75,9 @@ class BackgroundMigration "Batch size: #{batch_size}", "N. of batches sampled: #{batches_sampled}", "N. of failed batches: #{batches_failed.size}" - ] + ].tap do |info| + info << "Failed batches: #{names_of_batches_failed}" if batches_failed.present? + end end def success? @@ -109,6 +111,10 @@ class BackgroundMigration end def batches_failed - batches.select { |batch| !batch.success? } + @batches_failed ||= batches.select { |batch| !batch.success? } + end + + def names_of_batches_failed + batches_failed.map { |b| b.name || b.statistics['name'] }.join(',') end end diff --git a/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt b/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt index 3382bf10..7f8a0077 100644 --- a/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt +++ b/notifier/spec/fixtures/migration-testing/v4/expected-comment.txt @@ -244,6 +244,7 @@ Migrations included in this change have been executed on gitlab.com data for tes - Batch size: 150 - N. of batches sampled: 5 - N. of failed batches: 1 + - Failed batches: batch_5 Time estimation is conservative and based on sampling production data in a test environment. It represents the max time that migration could take. The actual time may differ from this estimation. -- GitLab