Commit fbe18998 authored by Jacob Schatz's avatar Jacob Schatz Committed by Micaël Bergeron

Add settings page for enabling gitlab elt database dump.

parent e461650f
= form_for @application_setting, url: admin_application_settings_path, html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting)
%fieldset
.form-group.row
.offset-sm-2.col-sm-10
- can_be_configured = @application_setting.elt_database_dump_can_be_configured?
.form-check
= f.label :elt_database_dump_enabled do
= f.check_box :elt_database_dump_enabled, disabled: !can_be_configured
Enable ELT Database Cron Job
.form-text.text-muted
- if can_be_configured
GitLab will run a cron job which will send pseudoanonymized data to be processed and analyzed.
- else
The ELT database cron job is disabled. When enabled the cron job will send pseudoanonymized data to be processed and analyzed.
= f.submit 'Save changes', class: "btn btn-success"
......@@ -237,6 +237,17 @@
.settings-content
= render 'usage'
%section.settings.as-usage.no-animate#js-elt-database-dump-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _('ELT Database Cron Job')
%button.btn.btn-default.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _('Enable or disable ELT Database Cron Job.')
.settings-content
= render 'elt_database_cron_job'
%section.settings.as-email.no-animate#js-email-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
......
class GitlabELTDataDumpWorker
include ApplicationWorker
include CronjobQueue
def perform
return unless Gitlab::CurrentSettings.elt_database_dump_enabled
Pseudonymity::Table.new.tables_to_csv
end
end
......@@ -162,6 +162,7 @@ Settings.gitlab['import_sources'] ||= Gitlab::ImportSources.values
Settings.gitlab['trusted_proxies'] ||= []
Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml'))
Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil?
Settings.gitlab['elt_database_dump_enabled'] = true if Settings.gitlab['elt_database_dump_enabled'].nil?
#
# Elasticseacrh
......@@ -370,6 +371,10 @@ Settings.cron_jobs['gitlab_usage_ping_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['gitlab_usage_ping_worker']['cron'] ||= Settings.__send__(:cron_for_usage_ping)
Settings.cron_jobs['gitlab_usage_ping_worker']['job_class'] = 'GitlabUsagePingWorker'
Settings.cron_jobs['gitlab_elt_database_dump'] ||= Settingslogic.new({})
Settings.cron_jobs['gitlab_elt_database_dump']['cron'] ||= '0 23 * * *';
Settings.cron_jobs['gitlab_elt_database_dump']['job_class'] ||= 'GitlabELTDataDumpWorker';
Settings.cron_jobs['schedule_update_user_activity_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['schedule_update_user_activity_worker']['cron'] ||= '30 0 * * *'
Settings.cron_jobs['schedule_update_user_activity_worker']['job_class'] = 'ScheduleUpdateUserActivityWorker'
......
......@@ -206,6 +206,7 @@ ActiveRecord::Schema.define(version: 20180612175636) do
t.string "encrypted_external_auth_client_key_pass_iv"
t.string "email_additional_text"
t.boolean "enforce_terms", default: false
t.boolean "elt_database_dump_enabled"
end
create_table "approvals", force: :cascade do |t|
......@@ -1631,6 +1632,7 @@ ActiveRecord::Schema.define(version: 20180612175636) do
t.text "title_html"
t.text "description_html"
t.integer "time_estimate"
t.boolean "squash", default: false, null: false
t.integer "cached_markdown_version"
t.datetime "last_edited_at"
t.integer "last_edited_by_id"
......@@ -2020,9 +2022,9 @@ ActiveRecord::Schema.define(version: 20180612175636) do
t.datetime "next_execution_timestamp"
t.string "status"
t.string "jid"
t.text "last_error"
t.datetime_with_timezone "last_update_at"
t.datetime_with_timezone "last_successful_update_at"
t.text "last_error"
end
add_index "project_mirror_data", ["jid"], name: "index_project_mirror_data_on_jid", using: :btree
......@@ -2277,6 +2279,7 @@ ActiveRecord::Schema.define(version: 20180612175636) do
end
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"}
add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree
create_table "releases", force: :cascade do |t|
......
......@@ -55,7 +55,8 @@ module EE
:slack_app_id,
:slack_app_secret,
:slack_app_verification_token,
:allow_group_owners_to_manage_ldap
:allow_group_owners_to_manage_ldap,
:elt_database_dump_enabled
]
end
......
......@@ -100,11 +100,20 @@ module EE
slack_app_enabled: false,
slack_app_id: nil,
slack_app_secret: nil,
slack_app_verification_token: nil
slack_app_verification_token: nil,
elt_database_dump_enabled: Settings.gitlab['elt_database_dump_enabled'],
)
end
end
def elt_database_dump_can_be_configured?
Settings.gitlab.elt_database_dump_enabled
end
def elt_database_dump_enabled
elt_database_dump_can_be_configured? && super
end
def should_check_namespace_plan?
check_namespace_plan? && (Rails.env.test? || ::Gitlab.dev_env_or_com?)
end
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddEltDumpEnabledToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
# DOWNTIME_REASON = ''
# When using the methods "add_concurrent_index", "remove_concurrent_index" or
# "add_column_with_default" you must disable the use of transactions
# as these methods can not run in an existing transaction.
# When using "add_concurrent_index" or "remove_concurrent_index" methods make sure
# that either of them is the _only_ method called in the migration,
# any other changes should go in a separate migration.
# This ensures that upon failure _only_ the index creation or removing fails
# and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def change
add_column :application_settings, :elt_database_dump_enabled, :boolean
end
end
......@@ -26,8 +26,6 @@ describe Gitlab::Pseudonymity do
project_table_file = pseudo.tables_to_csv[0]
# Ignore the `.` and `..` in the directory.
entry = Dir.entries(base_dir)[2]
expect(project_table_file.include? "projects_").to be true
expect(project_table_file.include? ".csv").to be true
columns = []
......
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