2020-03-03 10:08:08 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Admin
|
2020-10-14 20:08:42 -04:00
|
|
|
class Sidekiq < ::API::Base
|
2020-03-03 10:08:08 -05:00
|
|
|
before { authenticated_as_admin! }
|
|
|
|
|
2022-04-05 08:10:23 -04:00
|
|
|
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
|
2020-10-28 11:08:49 -04:00
|
|
|
|
2020-03-03 10:08:08 -05:00
|
|
|
namespace 'admin' do
|
|
|
|
namespace 'sidekiq' do
|
|
|
|
namespace 'queues' do
|
|
|
|
desc 'Drop jobs matching the given metadata from the Sidekiq queue'
|
|
|
|
params do
|
2021-09-14 05:11:32 -04:00
|
|
|
Gitlab::SidekiqQueue::ALLOWED_KEYS.each do |key|
|
2020-03-03 10:08:08 -05:00
|
|
|
optional key, type: String, allow_blank: false
|
|
|
|
end
|
|
|
|
|
2021-09-14 05:11:32 -04:00
|
|
|
at_least_one_of(*Gitlab::SidekiqQueue::ALLOWED_KEYS)
|
2020-03-03 10:08:08 -05:00
|
|
|
end
|
|
|
|
delete ':queue_name' do
|
|
|
|
result =
|
|
|
|
Gitlab::SidekiqQueue
|
|
|
|
.new(params[:queue_name])
|
|
|
|
.drop_jobs!(declared_params, timeout: 30)
|
|
|
|
|
|
|
|
present result
|
|
|
|
rescue Gitlab::SidekiqQueue::NoMetadataError
|
|
|
|
render_api_error!("Invalid metadata: #{declared_params}", 400)
|
|
|
|
rescue Gitlab::SidekiqQueue::InvalidQueueError
|
|
|
|
not_found!(params[:queue_name])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|