Avoid sidekiq warning for FlushCounterIncrementsWorker
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
What does this MR do and why?
When working on another MR, I noticed the following sidekiq warning for FlushCounterIncrementsWorker. This MR avoids the following warning.
Job arguments to FlushCounterIncrementsWorker must be native JSON types, but :packages_size is a Symbol.
See https://github.com/sidekiq/sidekiq/wiki/Best-Practices
To disable this error, add `Sidekiq.strict_args!(false)` to your initializer.
At the momement, Sidekiq is able to handle Symbol arguments (non-native JSON type) by converting these arguments into String arguments. But currently sidekiq is configured to show a warning when a non-native JSON type such as Symbol is passed.
The changes in this MR ensures that String (native JSON type) are passed correctly to the FlushCounterIncrementsWorker in the first place and avoids that sidekiq has to convert the argument by themselves. But this way, sidekiq does not show the mentioned warning. This change is safe because the logic is not changed, but we avoid one warning.
The affected files are:
lib/gitlab/counters/buffered_counter.rbspec/lib/gitlab/counters/buffered_counter_spec.rbspec/models/project_daily_statistic_spec.rbspec/models/project_statistics_spec.rbspec/support/shared_examples/models/update_project_statistics_shared_examples.rbspec/support/shared_examples/models/concerns/counter_attribute_shared_examples.rbspec/workers/every_sidekiq_worker_spec.rbspec/workers/flush_counter_increments_worker_spec.rbspec/lib/gitlab/counters/buffered_counter_spec.rb
be rspec spec/lib/gitlab/counters/buffered_counter_spec.rb spec/models/project_daily_statistic_spec.rb spec/models/project_statistics_spec.rb spec/support/shared_examples/models/update_project_statistics_shared_examples.rb spec/support/shared_examples/models/concerns/counter_attribute_shared_examples.rb spec/workers/every_sidekiq_worker_spec.rb spec/workers/flush_counter_increments_worker_spec.rb spec/lib/gitlab/counters/buffered_counter_spec.rb
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.
MR Checklist (@gerardo-navarro)
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
Screenshots or screen recordings
No frontend changes.
With this MR, the terminal output does not include the sidekiq warning for FlushCounterIncrementsWorker.
How to set up and validate locally
- Run the test in this branch => you should not see the sidekiq warning in the console output
bundle exec be rspec spec/lib/gitlab/counters/buffered_counter_spec.rb spec/models/project_daily_statistic_spec.rb spec/models/project_statistics_spec.rb spec/support/shared_examples/models/update_project_statistics_shared_examples.rb spec/support/shared_examples/models/concerns/counter_attribute_shared_examples.rb spec/workers/every_sidekiq_worker_spec.rb spec/workers/flush_counter_increments_worker_spec.rb spec/lib/gitlab/counters/buffered_counter_spec.rb
- Run the test in the branch
master=> you will see the sidekiq warning in the console output
Job arguments to FlushCounterIncrementsWorker must be native JSON types, but :packages_size is a Symbol.
See https://github.com/sidekiq/sidekiq/wiki/Best-Practices
To disable this error, add `Sidekiq.strict_args!(false)` to your initializer.
Related to #383183 (closed)