Commit fe64fd67 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Mark the StageUpdateWorker as idempotent

This worker was already idempotent, it updates the status of a stage
based on the jobs inside it.

This also means we can safely deduplicate it.
parent a256e32a
...@@ -849,7 +849,7 @@ ...@@ -849,7 +849,7 @@
:urgency: :high :urgency: :high
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 5 :weight: 5
:idempotent: :idempotent: true
- :name: pipeline_processing:update_head_pipeline_for_merge_request - :name: pipeline_processing:update_head_pipeline_for_merge_request
:feature_category: :continuous_integration :feature_category: :continuous_integration
:has_external_dependencies: :has_external_dependencies:
......
# frozen_string_literal: true # frozen_string_literal: true
class StageUpdateWorker # rubocop:disable Scalability/IdempotentWorker class StageUpdateWorker
include ApplicationWorker include ApplicationWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
urgency :high urgency :high
idempotent!
def perform(stage_id) def perform(stage_id)
Ci::Stage.find_by_id(stage_id)&.update_legacy_status Ci::Stage.find_by_id(stage_id)&.update_legacy_status
end end
......
...@@ -12,6 +12,15 @@ describe StageUpdateWorker do ...@@ -12,6 +12,15 @@ describe StageUpdateWorker do
described_class.new.perform(stage.id) described_class.new.perform(stage.id)
end end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [stage.id] }
it 'results in the stage getting the skipped status' do
expect { subject }.to change { stage.reload.status }.from('pending').to('skipped')
expect { subject }.not_to change { stage.reload.status }
end
end
end end
context 'when stage does not exist' do context 'when stage does not exist' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment