debian-mirror-gitlab/lib/gitlab/import/set_async_jid.rb

28 lines
949 B
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
# The original import JID is the JID of the RepositoryImportWorker job,
# which will be removed once that job completes. Reusing that JID could
2020-06-23 00:09:42 +05:30
# result in Gitlab::Import::StuckProjectImportJobsWorker marking the job
# as stuck before we get to running Stage::ImportRepositoryWorker.
2019-09-04 21:01:54 +05:30
#
# We work around this by setting the JID to a custom generated one, then
# refreshing it in the various stages whenever necessary.
module Gitlab
module Import
module SetAsyncJid
2020-04-22 19:07:51 +05:30
def self.set_jid(import_state)
jid = generate_jid(import_state)
2019-09-04 21:01:54 +05:30
2022-01-26 12:08:38 +05:30
Gitlab::SidekiqStatus.set(jid, Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION, value: 2)
2019-09-04 21:01:54 +05:30
2020-04-22 19:07:51 +05:30
import_state.update_column(:jid, jid)
2019-09-04 21:01:54 +05:30
end
2020-04-22 19:07:51 +05:30
def self.generate_jid(import_state)
importer_name = import_state.class.name.underscore.dasherize
"async-import/#{importer_name}/#{import_state.project_id}"
2019-09-04 21:01:54 +05:30
end
end
end
end