Commit 56e6e8c5 authored by Stan Hu's avatar Stan Hu

Add setting to disable usage ping

parent f493c9a8
......@@ -118,6 +118,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:elasticsearch_search,
:elasticsearch_host,
:elasticsearch_port,
:usage_ping_enabled,
:repository_storage,
:enabled_git_access_protocol,
restricted_visibility_levels: [],
......
......@@ -151,6 +151,7 @@ class ApplicationSetting < ActiveRecord::Base
container_registry_token_expire_delay: 5,
elasticsearch_host: ENV['ELASTIC_HOST'] || 'localhost',
elasticsearch_port: ENV['ELASTIC_PORT'] || '9200',
usage_ping_enabled: true,
repository_storage: 'default',
user_default_external: false,
)
......
......@@ -55,6 +55,15 @@
= f.label :version_check_enabled do
= f.check_box :version_check_enabled
Version check enabled
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :usage_ping_enabled do
= f.check_box :usage_ping_enabled
Usage ping enabled
.help-block
Every week GitLab will report license usage back to a GitLab server.
Disable this option if you do not want this to occur.
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
......
......@@ -9,6 +9,8 @@ class GitlabUsagePingWorker
sidekiq_options queue: :default, retry: false
def perform
return unless current_application_settings.usage_ping_enabled
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
return unless try_obtain_lease
......
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160712171823) do
ActiveRecord::Schema.define(version: 20160713222618) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -94,7 +94,8 @@ ActiveRecord::Schema.define(version: 20160712171823) 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
create_table "approvals", force: :cascade do |t|
......
......@@ -19,10 +19,19 @@ describe GitlabUsagePingWorker do
end
it "sends POST request" do
stub_application_setting(usage_ping_enabled: true)
stub_request(:post, "https://version.gitlab.com/usage_ping").
to_return(status: 200, body: '', headers: {})
expect(subject).to receive(:try_obtain_lease).and_return(true)
expect(subject.perform.response.code.to_i).to eq(200)
end
it "does not run if usage ping is disabled" do
stub_application_setting(usage_ping_enabled: false)
expect(subject).not_to receive(:try_obtain_lease)
expect(subject).not_to receive(:perform)
end
end
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