Class: MergeRequestCleanupRefsWorker
- Inherits:
-
Object
- Object
- MergeRequestCleanupRefsWorker
- Includes:
- ApplicationWorker, Gitlab::Utils::StrongMemoize, LimitedCapacity::Worker
- Defined in:
- app/workers/merge_request_cleanup_refs_worker.rb
Constant Summary collapse
- MAX_RUNNING_JOBS =
Hard-coded to 4 for now. Will be configurable later on via application settings. This means, there can only be 4 jobs running at the same time at maximum.
4
- FAILURE_THRESHOLD =
3
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
Methods included from LimitedCapacity::Worker
#perform, #remove_failed_jobs, #report_prometheus_metrics
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#max_running_jobs ⇒ Object
54 55 56 |
# File 'app/workers/merge_request_cleanup_refs_worker.rb', line 54 def max_running_jobs MAX_RUNNING_JOBS end |
#perform_work ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/workers/merge_request_cleanup_refs_worker.rb', line 20 def perform_work return unless Feature.enabled?(:merge_request_refs_cleanup) unless merge_request logger.error('No existing merge request to be cleaned up.') return end (:merge_request_id, merge_request.id) result = MergeRequests::CleanupRefsService.new(merge_request).execute if result[:status] == :success merge_request_cleanup_schedule.complete! else if merge_request_cleanup_schedule.failed_count < FAILURE_THRESHOLD merge_request_cleanup_schedule.retry! else merge_request_cleanup_schedule.mark_as_failed! end (:message, result[:message]) end (:status, merge_request_cleanup_schedule.status) end |
#remaining_work_count ⇒ Object
47 48 49 50 51 52 |
# File 'app/workers/merge_request_cleanup_refs_worker.rb', line 47 def remaining_work_count MergeRequest::CleanupSchedule .scheduled_and_unstarted .limit(max_running_jobs) .count end |