Class: Gitlab::Version::VersionCheckCronWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/gitlab/version/version_check_cron_worker.rb

Constant Summary

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

Instance Method Summary collapse

Methods included from Loggable

#build_structured_payload

Methods included from SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/gitlab/version/version_check_cron_worker.rb', line 21

def perform
  response = Gitlab::HTTP.try_get(url)

  if response.present? && response.code == 200
    result = Gitlab::Json.parse(response.body)
    Gitlab::AppLogger.info(message: 'Version check succeeded', result: result)

    Rails.cache.write("version_check", result)
  else
    Gitlab::AppLogger.error(message: 'Version check failed',
      error: { code: response&.code, message: response&.body })
  end
rescue JSON::ParserError => e
  Gitlab::AppLogger.error(message: 'Parsing version check response failed',
    error: { message: e.message, code: response&.code })
end