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

Merge branch 'allow-import-job-id-tracking-by-import-state-model' into 'master'

Track import job id by import state model

See merge request gitlab-org/gitlab!28604
parents 1ed71f63 05ce6a58
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
return unless start_import return unless start_import
Gitlab::Import::SetAsyncJid.set_jid(project) Gitlab::Import::SetAsyncJid.set_jid(project.import_state)
Gitlab::JiraImport::Stage::ImportLabelsWorker.perform_async(project.id) Gitlab::JiraImport::Stage::ImportLabelsWorker.perform_async(project.id)
end end
......
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
end end
def execute def execute
Gitlab::Import::SetAsyncJid.set_jid(project) Gitlab::Import::SetAsyncJid.set_jid(project.import_state)
Stage::ImportRepositoryWorker Stage::ImportRepositoryWorker
.perform_async(project.id) .perform_async(project.id)
......
...@@ -10,17 +10,18 @@ ...@@ -10,17 +10,18 @@
module Gitlab module Gitlab
module Import module Import
module SetAsyncJid module SetAsyncJid
def self.set_jid(project) def self.set_jid(import_state)
jid = generate_jid(project) jid = generate_jid(import_state)
Gitlab::SidekiqStatus Gitlab::SidekiqStatus
.set(jid, StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION) .set(jid, StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)
project.import_state.update_column(:jid, jid) import_state.update_column(:jid, jid)
end end
def self.generate_jid(project) def self.generate_jid(import_state)
"async-import/#{project.id}" importer_name = import_state.class.name.underscore.dasherize
"async-import/#{importer_name}/#{import_state.project_id}"
end end
end end
end end
......
...@@ -18,7 +18,7 @@ module Gitlab ...@@ -18,7 +18,7 @@ module Gitlab
end end
def execute def execute
Gitlab::Import::SetAsyncJid.set_jid(project) Gitlab::Import::SetAsyncJid.set_jid(project.import_state)
schedule_first_tasks_page schedule_first_tasks_page
true true
......
...@@ -27,7 +27,7 @@ describe Gitlab::GithubImport::ParallelImporter do ...@@ -27,7 +27,7 @@ describe Gitlab::GithubImport::ParallelImporter do
end end
it 'sets the JID in Redis' do it 'sets the JID in Redis' do
expect(Gitlab::Import::SetAsyncJid).to receive(:set_jid).with(project).and_call_original expect(Gitlab::Import::SetAsyncJid).to receive(:set_jid).with(project.import_state).and_call_original
importer.execute importer.execute
end end
......
...@@ -8,16 +8,16 @@ describe Gitlab::Import::SetAsyncJid do ...@@ -8,16 +8,16 @@ describe Gitlab::Import::SetAsyncJid do
it 'sets the JID in Redis' do it 'sets the JID in Redis' do
expect(Gitlab::SidekiqStatus) expect(Gitlab::SidekiqStatus)
.to receive(:set) .to receive(:set)
.with("async-import/#{project.id}", StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION) .with("async-import/project-import-state/#{project.id}", StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)
.and_call_original .and_call_original
described_class.set_jid(project) described_class.set_jid(project.import_state)
end end
it 'updates the import JID of the project' do it 'updates the import JID of the project' do
described_class.set_jid(project) described_class.set_jid(project.import_state)
expect(project.import_state.reload.jid).to eq("async-import/#{project.id}") expect(project.import_state.reload.jid).to eq("async-import/project-import-state/#{project.id}")
end end
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