Docs: Remove Sidekiq jobs for given parameters (destructive)
To find the arguments for a specific queue, you can have a look at the
perform
function of the related worker file, commonly found at/app/workers/<queue-name>_worker.rb
.For example,
repository_import
hasproject_id
as the job argument, whileupdate_merge_requests
hasproject_id, user_id, oldrev, newrev, ref
.
Let’s assume we’re using 17.0.0
(or later), find an interesting-looking worker and build an example.
Interesting Options
A few things to keep in mind when investigating Sidekiq stuff:
- You can use
bin/rake gitlab:sidekiq:all_queues_yml:generate
to regenerate the file that’s atapp/workers/all_queues.yml
.- That file is useful for understanding the naming convention of various Sidekiq workers.
- Check out what that Rake task does.
- The tools in the
toolbox
pod permit Sidekiq maintenance in Helm-based deployments.
AuditEvents::AuditEventStreamingWorker
ee/app/workers/audit_events/audit_event_streaming_worker.rb
- AuditEventStreamingWorker enqueued for all groups regardless of destinations
- Enqueue audit streaming only for groups with streaming destinations
Extant Examples
0:
queue = Sidekiq::Queue.new('package_metadata_advisory_scan')
queue.each { |job| job.delete }
1:
Sidekiq::Queue.new('authorized_projects').to_enum.map { |j| j['meta.user'] }
2:
require 'sidekiq/api'
pages_remove_queue = Sidekiq::Queue.new("pages_remove")
pages_remove_queue.clear