Fix epic work item rake task progressbar
What does this MR do and why?
Fix epic work item rake task progressbar
Since the cardinality is only estimated, it might be the case that we increase the actual progress above the total limit. To prevent this, we add a guard.
Replaces fast_spec_helper
with spec_helper
. Running the spec
alone would otherwise not work.
Changelog: fixed EE: true
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
When the estimated cardinality is not correct, we get the following error otherwise:
| 0/329
ProgressBar::InvalidProgressError: You can’t set the item’s current value to be greater than the total.
/Users/nicolas/gitlab-development-kit/gitlab/ee/lib/tasks/gitlab/work_items/epics.rake:22:in `block (5 levels) in <main>’
/Users/nicolas/gitlab-development-kit/gitlab/ee/lib/gitlab/epic_work_item_sync/bulk_verification.rb:27:in `block in verify’
/Users/nicolas/gitlab-development-kit/gitlab/app/models/concerns/each_batch.rb:102:in `block (2 levels) in each_batch’
/Users/nicolas/gitlab-development-kit/gitlab/app/models/concerns/each_batch.rb:102:in `block in each_batch’
/Users/nicolas/gitlab-development-kit/gitlab/app/models/concerns/each_batch.rb:72:in `step’
/Users/nicolas/gitlab-development-kit/gitlab/app/models/concerns/each_batch.rb:72:in `each_batch’
/Users/nicolas/gitlab-development-kit/gitlab/ee/lib/gitlab/epic_work_item_sync/bulk_verification.rb:15:in `verify’
/Users/nicolas/gitlab-development-kit/gitlab/ee/lib/tasks/gitlab/work_items/epics.rake:22:in `block (4 levels) in <main>’
/Users/nicolas/.asdf/installs/ruby/3.2.4/bin/bundle:25:in `load’
/Users/nicolas/.asdf/installs/ruby/3.2.4/bin/bundle:25:in `<main>’
Tasks: TOP => gitlab:work_items:epics:enable
(See full trace by running task with —trace)
Before | After |
---|---|
How to set up and validate locally
Without this fix, apply the following diff
diff --git a/ee/lib/tasks/gitlab/work_items/epics.rake b/ee/lib/tasks/gitlab/work_items/epics.rake
index dacc1083bfc8..a0827ec09b36 100644
--- a/ee/lib/tasks/gitlab/work_items/epics.rake
+++ b/ee/lib/tasks/gitlab/work_items/epics.rake
@@ -15,7 +15,7 @@ namespace :gitlab do
progress_bar ||= ProgressBar.create(
title: 'Verifying epics',
- total: Gitlab::Database::PgClass.for_table('epics')&.cardinality_estimate,
+ total: (Gitlab::Database::PgClass.for_table('epics')&.cardinality_estimate&.- 20),
format: '%t: |%B| %c/%C'
)
And run the rake task to see the error:
bundle exec rake gitlab:work_items:epics:enable
Numbered steps to set up and validate the change are strongly suggested.