Class: Gitlab::Import::RefreshImportJidWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/gitlab/import/refresh_import_jid_worker.rb

Constant Summary collapse

INTERVAL =

The interval to schedule new instances of this job at.

5.minutes.to_i

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Loggable

Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#build_structured_payload

Methods included from SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Class Method Details

.perform_in_the_future(*args) ⇒ Object



19
20
21
# File 'app/workers/gitlab/import/refresh_import_jid_worker.rb', line 19

def self.perform_in_the_future(*args)
  perform_in(INTERVAL, *args)
end

Instance Method Details

#perform(project_id, check_job_id, _params = {}) ⇒ Object

project_id - The ID of the project that is being imported. check_job_id - The ID of the job for which to check the status. params - to avoid multiple releases if parameters change



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/workers/gitlab/import/refresh_import_jid_worker.rb', line 26

def perform(project_id, check_job_id, _params = {})
  return unless SidekiqStatus.running?(check_job_id)

  import_state_jid = ProjectImportState.jid_by(project_id: project_id, status: :started)&.jid
  return unless import_state_jid

  # As long as the worker is running we want to keep refreshing
  # the worker's JID as well as the import's JID.
  Gitlab::SidekiqStatus.expire(check_job_id, Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION)
  Gitlab::SidekiqStatus.set(import_state_jid, Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION)

  self.class.perform_in_the_future(project_id, check_job_id)
end