Commit 2d558d25 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '18500-zero-work-idempotency' into 'master'

Mark the `PostReceive` worker as idempotent

See merge request gitlab-org/gitlab!69305
parents 27d0ea79 cb87e136
...@@ -2445,7 +2445,7 @@ ...@@ -2445,7 +2445,7 @@
:urgency: :high :urgency: :high
:resource_boundary: :cpu :resource_boundary: :cpu
:weight: 5 :weight: 5
:idempotent: :idempotent: true
:tags: [] :tags: []
- :name: process_commit - :name: process_commit
:worker_name: ProcessCommitWorker :worker_name: ProcessCommitWorker
......
# frozen_string_literal: true # frozen_string_literal: true
class PostReceive # rubocop:disable Scalability/IdempotentWorker class PostReceive
include ApplicationWorker include ApplicationWorker
idempotent!
deduplicate :none
data_consistency :always data_consistency :always
sidekiq_options retry: 3 sidekiq_options retry: 3
......
...@@ -22,6 +22,8 @@ RSpec.describe PostReceive do ...@@ -22,6 +22,8 @@ RSpec.describe PostReceive do
create(:project, :repository, auto_cancel_pending_pipelines: 'disabled') create(:project, :repository, auto_cancel_pending_pipelines: 'disabled')
end end
let(:job_args) { [gl_repository, key_id, base64_changes] }
def perform(changes: base64_changes) def perform(changes: base64_changes)
described_class.new.perform(gl_repository, key_id, changes) described_class.new.perform(gl_repository, key_id, changes)
end end
...@@ -282,6 +284,8 @@ RSpec.describe PostReceive do ...@@ -282,6 +284,8 @@ RSpec.describe PostReceive do
end end
end end
end end
it_behaves_like 'an idempotent worker'
end end
describe '#process_wiki_changes' do describe '#process_wiki_changes' do
...@@ -352,6 +356,8 @@ RSpec.describe PostReceive do ...@@ -352,6 +356,8 @@ RSpec.describe PostReceive do
perform perform
end end
end end
it_behaves_like 'an idempotent worker'
end end
context 'webhook' do context 'webhook' do
...@@ -458,6 +464,8 @@ RSpec.describe PostReceive do ...@@ -458,6 +464,8 @@ RSpec.describe PostReceive do
end end
end end
end end
it_behaves_like 'an idempotent worker'
end end
context 'with PersonalSnippet' do context 'with PersonalSnippet' do
...@@ -484,5 +492,7 @@ RSpec.describe PostReceive do ...@@ -484,5 +492,7 @@ RSpec.describe PostReceive do
described_class.new.perform(gl_repository, key_id, base64_changes) described_class.new.perform(gl_repository, key_id, base64_changes)
end end
it_behaves_like 'an idempotent worker'
end end
end end
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