Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
87e0baed
Commit
87e0baed
authored
Jul 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
cdbac64a
0067ea31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
app/workers/gitlab_usage_ping_worker.rb
app/workers/gitlab_usage_ping_worker.rb
+6
-0
changelogs/unreleased/bjk-usage_ping.yml
changelogs/unreleased/bjk-usage_ping.yml
+5
-0
config/settings.rb
config/settings.rb
+9
-5
No files found.
app/workers/gitlab_usage_ping_worker.rb
View file @
87e0baed
...
...
@@ -6,10 +6,16 @@ class GitlabUsagePingWorker
include
ApplicationWorker
include
CronjobQueue
# Retry for up to approximately three hours then give up.
sidekiq_options
retry:
10
,
dead:
false
def
perform
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
return
unless
try_obtain_lease
# Splay the request over a minute to avoid thundering herd problems.
sleep
(
rand
(
0.0
..
60.0
).
round
(
3
))
SubmitUsagePingService
.
new
.
execute
end
...
...
changelogs/unreleased/bjk-usage_ping.yml
0 → 100644
View file @
87e0baed
---
title
:
Update usage ping cron behavior
merge_request
:
30842
author
:
type
:
performance
config/settings.rb
View file @
87e0baed
require
'settingslogic'
require
'digest/md5'
# We can not use `Rails.root` here, as this file might be loaded without the
# full Rails environment being loaded. We can not use `require_relative` either,
...
...
@@ -170,14 +171,17 @@ class Settings < Settingslogic
URI
.
parse
(
url_without_path
).
host
end
# Runs
every minute in a random ten-minute period on Sundays, to balance the
#
load on the server receiving these pings. The usage ping is safe to run
#
multiple times because of a 24 hour exclusive lock
.
# Runs
at a random time of day on a consistent 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
(
6
)
minute
=
rand
(
60
)
# Set a default UUID for the case when the UUID hasn't been initialized.
uuid
=
Gitlab
::
CurrentSettings
.
uuid
||
'uuid-not-set'
day_of_week
=
Digest
::
MD5
.
hexdigest
(
uuid
).
to_i
(
16
)
%
7
"
#{
minute
}
0-
#{
minute
}
9
#{
hour
}
* * 0
"
"
#{
minute
}
#{
hour
}
* *
#{
day_of_week
}
"
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment