Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/settings.rb')
-rw-r--r--config/settings.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/config/settings.rb b/config/settings.rb
index 99f1b85202e..c681fa32491 100644
--- a/config/settings.rb
+++ b/config/settings.rb
@@ -184,14 +184,15 @@ class Settings < Settingslogic
URI.parse(url_without_path).host
end
- # Runs at a random time of day on a consistent day of the week based on
+ # Runs at a consistent random time of day on a day of the week based on
# the instance UUID. This is to balance the load on the service receiving
# these pings. The sidekiq job handles temporary http failures.
def cron_for_usage_ping
- hour = rand(24)
- minute = rand(60)
# Set a default UUID for the case when the UUID hasn't been initialized.
uuid = Gitlab::CurrentSettings.uuid || 'uuid-not-set'
+
+ minute = Digest::MD5.hexdigest(uuid + 'minute').to_i(16) % 60
+ hour = Digest::MD5.hexdigest(uuid + 'hour').to_i(16) % 24
day_of_week = Digest::MD5.hexdigest(uuid).to_i(16) % 7
"#{minute} #{hour} * * #{day_of_week}"