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.rb
  • 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

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

🛠 with at Siemens

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)

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

  1. 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
  1. 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)

Edited by Gerardo Navarro

Merge request reports

Loading