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

Merge branch 'make-import-issues-csv-worker-idempotent' into 'master'

Make ImportIssuesCsvWorker idempotent

See merge request gitlab-org/gitlab!47808
parents fa37bef6 9adb90fa
......@@ -1609,7 +1609,7 @@
:urgency: :low
:resource_boundary: :cpu
:weight: 2
:idempotent:
:idempotent: true
:tags: []
- :name: invalid_gpg_signature_update
:feature_category: :source_code_management
......
......@@ -3,6 +3,7 @@
class ImportIssuesCsvWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
idempotent!
feature_category :issue_tracking
worker_resource_boundary :cpu
weight 2
......@@ -12,13 +13,15 @@ class ImportIssuesCsvWorker # rubocop:disable Scalability/IdempotentWorker
end
def perform(current_user_id, project_id, upload_id)
@user = User.find(current_user_id)
@project = Project.find(project_id)
@upload = Upload.find(upload_id)
user = User.find(current_user_id)
project = Project.find(project_id)
upload = Upload.find(upload_id)
importer = Issues::ImportCsvService.new(@user, @project, @upload.retrieve_uploader)
importer = Issues::ImportCsvService.new(user, project, upload.retrieve_uploader)
importer.execute
@upload.destroy
upload.destroy
rescue ActiveRecord::RecordNotFound
# Resources have been removed, job should not be retried
end
end
---
title: Make ImportIssuesCsvWorker idempotent
merge_request: 47808
author:
type: changed
......@@ -3,9 +3,9 @@
require 'spec_helper'
RSpec.describe ImportIssuesCsvWorker do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:upload) { create(:upload) }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let(:upload) { create(:upload, :with_file) }
let(:worker) { described_class.new }
......@@ -19,5 +19,9 @@ RSpec.describe ImportIssuesCsvWorker do
expect { upload.reload }.to raise_error ActiveRecord::RecordNotFound
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [user.id, project.id, upload.id] }
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