Commit 150aee0e authored by Stan Hu's avatar Stan Hu

Add license fingerprint and catch errors in HTTParty

parent 3d4fce06
......@@ -62,7 +62,7 @@
= f.check_box :usage_ping_enabled
Usage ping enabled
.help-block
Every week GitLab will report license usage back to a GitLab server.
Every week GitLab will report license usage back to GitLab, Inc.
Disable this option if you do not want this to occur.
.form-group
.col-sm-offset-2.col-sm-10
......
......@@ -14,10 +14,14 @@ class GitlabUsagePingWorker
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
return unless try_obtain_lease
HTTParty.post(url,
body: data.to_json,
headers: { 'Content-type' => 'application/json' }
)
begin
HTTParty.post(url,
body: data.to_json,
headers: { 'Content-type' => 'application/json' }
)
rescue HTTParty::Error => e
Rails.logger.info "Unable to contact GitLab, Inc.: #{e}"
end
end
def try_obtain_lease
......@@ -30,6 +34,7 @@ class GitlabUsagePingWorker
license = License.current
if license
usage_data[:license_md5] = Digest::MD5.hexdigest(license.data)
usage_data[:historical_max_users] = max_historical_user_count
usage_data[:licensee] = license.licensee
usage_data[:license_user_count] = license.user_count
......
......@@ -94,7 +94,7 @@ ActiveRecord::Schema.define(version: 20160713222618) do
t.string "elasticsearch_host", default: "localhost"
t.string "elasticsearch_port", default: "9200"
t.string "repository_storage", default: "default"
t.string "enabled_git_access_protocol",
t.string "enabled_git_access_protocol"
t.boolean "usage_ping_enabled", default: true, null: false
end
......
......@@ -7,6 +7,7 @@ describe GitlabUsagePingWorker do
data = subject.data
license = License.current
expect(data[:license_md5]).to eq(Digest::MD5.hexdigest(license.data))
expect(data[:version]).to eq(Gitlab::VERSION)
expect(data[:licensee]).to eq(license.licensee)
expect(data[:active_users]).to eq(User.active.count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment