BBM - Estimate time remaining follow up
Ref: #589188 (closed)
What does this MR do and why?
Following up !221255 (merged)
This MR immproves estimated time remaining display and error handling.
- CLI improvements: Combines progress and estimated time remaining into a single column for better readability
- Admin UI: Adds estimated time remaining to the background migrations view
- Error handling: Adds rescue mechanism to handle query failures gracefully
Testing
- Create a new BBM
- Run CLI command
- Visit admin UI
Click to expand
Gitlab::Database::SharedModel.using_connection(ActiveRecord::Base.connection) do
migration = Gitlab::Database::BackgroundMigration::BatchedMigration.create!(
job_class_name: 'TestMigration',
table_name: 'users',
column_name: 'id',
interval: 120,
min_value: 1,
max_value: 1000,
batch_size: 100,
sub_batch_size: 10,
total_tuple_count: 100,
status: 1,
gitlab_schema: :gitlab_main
)
migration.batched_jobs.create!(
status: 3,
batch_size: 50,
sub_batch_size: 10,
pause_ms: 100,
min_value: 1,
max_value: 50,
started_at: 60.seconds.ago,
finished_at: Time.current
)
end
➜ gitlab git:(morefice/bbm-estimate-time-remaining-2) ✗ bundle exec rake gitlab:background_migrations:list
id | table_name | job_class_name | status | progress
-------|-------------------------------|------------------------------------------------------|----------|---------------------------------------------
main_1 | plan_limits | BackfillPlanLimitsPlanNameUid | finished | 100.00%
main_2 | gitlab_subscriptions | BackfillGitlabSubscriptionsHostedPlanNameUid | finished | 100.00%
main_3 | gitlab_subscription_histories | BackfillGitlabSubscriptionHistoriesHostedPlanNameUid | finished | 100.00%
main_4 | users | TestMigration | active | 50.00% (estimated time remaining: 2 minutes)
ci_1 | ci_pending_builds | BackfillCiPendingBuildsPlanNameUid | finished | 100.00%
ci_2 | ci_runners | BackfillCiRunnersAllowedPlanNameUids | finished | 100.00%
