2018-11-08 19:23:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
class GitlabServicePingWorker # rubocop:disable Scalability/IdempotentWorker
|
|
|
|
LEASE_KEY = 'gitlab_service_ping_worker:ping'
|
2017-08-17 22:00:37 +05:30
|
|
|
LEASE_TIMEOUT = 86400
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
include ApplicationWorker
|
2020-10-24 23:57:45 +05:30
|
|
|
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
|
|
|
|
include Gitlab::ExclusiveLeaseHelpers
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
feature_category :service_ping
|
2020-10-24 23:57:45 +05:30
|
|
|
sidekiq_options retry: 3, dead: false
|
|
|
|
sidekiq_retry_in { |count| (count + 1) * 8.hours.to_i }
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def perform
|
2021-09-30 23:02:18 +05:30
|
|
|
# Disable service ping for GitLab.com
|
2021-02-22 17:27:13 +05:30
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/292929 for details
|
|
|
|
return if Gitlab.com?
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
|
2020-10-24 23:57:45 +05:30
|
|
|
in_lock(LEASE_KEY, ttl: LEASE_TIMEOUT) do
|
|
|
|
# Splay the request over a minute to avoid thundering herd problems.
|
|
|
|
sleep(rand(0.0..60.0).round(3))
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
ServicePing::SubmitService.new.execute
|
2020-10-24 23:57:45 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|