Commit cb87e136 authored by Nick Thomas's avatar Nick Thomas

Mark the PostReceive worker as idempotent

This worker does have side-effects, such as sending webhooks and
creating push events, but it is safe to duplicate them.

It is not safe to deduplicate this queue.

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