Skip to content

Add a feature to remove sidekiq jobs from queues based on metadata

In #89 (closed) we'll document how admins can remove sidekiq jobs from queues based on metadata.

As a next step, this should be added to the application itself.

The administrator can specify the queue to delete jobs based on metadata, this can contain any field from Labkit::Context::KNOWN_KEYS.

The request would be a DELETE to /api/v4/admin/sidekiq/queues/:queue_name with the context attributes.

For example:

curl --request DELETE --header "PRIVATE-TOKEN: <ADMIN_API_TOKEN>" https://gitlab.com/api/v4/admin/sidekiq/queues/post_receive -d user='reprazent' -d root_namespace='gitlab-org'

Would delete all the jobs in the post_receive queue, with meta.user = reprazent and meta.root_namespace = gitlab-org.

The response would include the number of jobs that were removed:

{
  deleted_jobs: 123
  queue_processed: true
}

We need to make sure this request stops before reaching the worker timeout. If the queue_processed boolean is false it means we hit the timeout and aborted cleaning up before reaching the end of the queue.

Suggestion: Build this GraphQL first and use that in the REST api.

Edited by Sean McGivern