diff options
Diffstat (limited to 'app/workers/gitlab_service_ping_worker.rb')
-rw-r--r-- | app/workers/gitlab_service_ping_worker.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/workers/gitlab_service_ping_worker.rb b/app/workers/gitlab_service_ping_worker.rb index a974667e5e0..b02e7318585 100644 --- a/app/workers/gitlab_service_ping_worker.rb +++ b/app/workers/gitlab_service_ping_worker.rb @@ -15,17 +15,24 @@ class GitlabServicePingWorker # rubocop:disable Scalability/IdempotentWorker sidekiq_options retry: 3, dead: false sidekiq_retry_in { |count| (count + 1) * 8.hours.to_i } - def perform - # Disable service ping for GitLab.com + def perform(options = {}) + # Sidekiq does not support keyword arguments, so the args need to be + # passed the old pre-Ruby 2.0 way. + # + # See https://github.com/mperham/sidekiq/issues/2372 + triggered_from_cron = options.fetch('triggered_from_cron', true) + skip_db_write = options.fetch('skip_db_write', false) + + # Disable service ping for GitLab.com unless called manually # See https://gitlab.com/gitlab-org/gitlab/-/issues/292929 for details - return if Gitlab.com? + return if Gitlab.com? && triggered_from_cron # Multiple Sidekiq workers could run this. We should only do this at most once a day. 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)) - ServicePing::SubmitService.new(payload: usage_data).execute + ServicePing::SubmitService.new(payload: usage_data, skip_db_write: skip_db_write).execute end end |