diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-05 03:09:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-05 03:09:46 +0000 |
commit | f3d84c4f06cec626f03d3d1fb73051b1a962397d (patch) | |
tree | 88f7841301d4b3fe7b9e14392dc1befb3ed38261 | |
parent | 2b4ad9a839c3c8a99b2a8f5cdcb1f30421f3ff3e (diff) | |
download | gitlab-ce-f3d84c4f06cec626f03d3d1fb73051b1a962397d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/helpers/preferences_helper.rb | 2 | ||||
-rw-r--r-- | app/services/concerns/spam_check_methods.rb | 2 | ||||
-rw-r--r-- | app/services/spam/spam_action_service.rb | 4 | ||||
-rw-r--r-- | doc/administration/operations/extra_sidekiq_processes.md | 94 | ||||
-rw-r--r-- | lib/gitlab/i18n.rb | 40 | ||||
-rw-r--r-- | locale/gitlab.pot | 21 | ||||
-rw-r--r-- | spec/graphql/mutations/issues/update_spec.rb | 2 | ||||
-rw-r--r-- | spec/helpers/preferences_helper_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/spam_action_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/support/matchers/graphql_matchers.rb | 10 |
10 files changed, 108 insertions, 71 deletions
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 070089d6ef8..7a0462e1b2c 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -70,7 +70,7 @@ module PreferencesHelper end def language_choices - Gitlab::I18n::AVAILABLE_LANGUAGES.map { |value, label| [label, value] } + Gitlab::I18n::AVAILABLE_LANGUAGES.map(&:reverse).sort end private diff --git a/app/services/concerns/spam_check_methods.rb b/app/services/concerns/spam_check_methods.rb index 84a79261915..53e9e001463 100644 --- a/app/services/concerns/spam_check_methods.rb +++ b/app/services/concerns/spam_check_methods.rb @@ -30,7 +30,7 @@ module SpamCheckMethods api: @api, recaptcha_verified: @recaptcha_verified, spam_log_id: @spam_log_id, - user_id: user.id) + user: user) end # rubocop:enable Gitlab/ModuleWithInstanceVariables end diff --git a/app/services/spam/spam_action_service.rb b/app/services/spam/spam_action_service.rb index 6907a42c7dd..0c938ba00c2 100644 --- a/app/services/spam/spam_action_service.rb +++ b/app/services/spam/spam_action_service.rb @@ -22,11 +22,11 @@ module Spam end end - def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:) + def execute(api: false, recaptcha_verified:, spam_log_id:, user:) if recaptcha_verified # If it's a request which is already verified through reCAPTCHA, # update the spam log accordingly. - SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id) + SpamLog.verify_recaptcha!(user_id: user.id, id: spam_log_id) else return unless request return unless check_for_spam? diff --git a/doc/administration/operations/extra_sidekiq_processes.md b/doc/administration/operations/extra_sidekiq_processes.md index 1c92a429982..f53dc129b14 100644 --- a/doc/administration/operations/extra_sidekiq_processes.md +++ b/doc/administration/operations/extra_sidekiq_processes.md @@ -20,26 +20,21 @@ can be started. ## Starting multiple processes -To start multiple Sidekiq processes, you must enable `sidekiq-cluster`: +To start multiple processes: -1. Edit `/etc/gitlab/gitlab.rb` and add: - - ```ruby - sidekiq_cluster['enable'] = true - ``` - -1. You will then need to specify how many additional processes to create via `sidekiq-cluster` - and which queue they should handle via the `sidekiq_cluster['queue_groups']` - array setting. Each item in the array equates to one additional Sidekiq +1. Using the `sidekiq['queue_groups']` array setting, specify how many processes to + create using `sidekiq-cluster` and which queue they should handle. + Each item in the array equates to one additional Sidekiq process, and values in each item determine the queues it works on. - For example, the following setting adds additional Sidekiq processes to two - queues, one to `elastic_indexer` and one to `mailers`: + For example, the following setting creates three Sidekiq processes, one to run on + `elastic_indexer`, one to run on `mailers`, and one process running all on queues: ```ruby - sidekiq_cluster['queue_groups'] = [ + sidekiq['queue_groups'] = [ "elastic_indexer", - "mailers" + "mailers", + "*" ] ``` @@ -47,9 +42,10 @@ To start multiple Sidekiq processes, you must enable `sidekiq-cluster`: queue names to its item delimited by commas. For example: ```ruby - sidekiq_cluster['queue_groups'] = [ + sidekiq['queue_groups'] = [ "elastic_indexer, elastic_commit_indexer", - "mailers" + "mailers", + "*" ] ``` @@ -58,7 +54,7 @@ To start multiple Sidekiq processes, you must enable `sidekiq-cluster`: processes, each handling all queues: ```ruby - sidekiq_cluster['queue_groups'] = [ + sidekiq['queue_groups'] = [ "*", "*" ] @@ -67,6 +63,14 @@ To start multiple Sidekiq processes, you must enable `sidekiq-cluster`: `*` cannot be combined with concrete queue names - `*, mailers` will just handle the `mailers` queue. + When `sidekiq-cluster` is only running on a single node, make sure that at least + one process is running on all queues using `*`. This means a process will + automatically pick up jobs in queues created in the future. + + If `sidekiq-cluster` is running on more than one node, you can also use + [`--negate`](#negating-settings) and list all the queues that are already being + processed. + 1. Save the file and reconfigure GitLab for the changes to take effect: ```shell @@ -87,7 +91,7 @@ you list: edit `/etc/gitlab/gitlab.rb` and add: ```ruby - sidekiq_cluster['negate'] = true + sidekiq['negate'] = true ``` 1. Save the file and reconfigure GitLab for the changes to take effect: @@ -177,9 +181,9 @@ entire queue group selects all queues. In `/etc/gitlab/gitlab.rb`: ```ruby -sidekiq_cluster['enable'] = true -sidekiq_cluster['experimental_queue_selector'] = true -sidekiq_cluster['queue_groups'] = [ +sidekiq['enable'] = true +sidekiq['experimental_queue_selector'] = true +sidekiq['queue_groups'] = [ # Run all non-CPU-bound queues that are high urgency 'resource_boundary!=cpu&urgency=high', # Run all continuous integration and pages queues that are not high urgency @@ -189,35 +193,34 @@ sidekiq_cluster['queue_groups'] = [ ] ``` -### Using Sidekiq cluster by default (experimental) +### Migrating to Sidekiq-cluster -> [Introduced](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/4006) in GitLab 12.10. +> - [Introduced](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/4006) in GitLab 12.10. +> - [Moved](https://gitlab.com/groups/gitlab-com/gl-infra/-/epics/181) to GitLab [Core](https://about.gitlab.com/pricing/#self-managed) in GitLab 12.10. CAUTION: **Warning:** -This feature is experimental. +Sidekiq cluster is [scheduled](https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/240) +to be the only way to start Sidekiq in GitLab 14.0. -We're moving [Sidekiq cluster to -core](https://gitlab.com/groups/gitlab-com/gl-infra/-/epics/181) and -plan to make it the default way of starting Sidekiq. - -Set the following to start Sidekiq (cluster) -process for handling for all queues (`/etc/gitlab/gitlab.rb`): +By default, the Sidekiq service will run `sidekiq-cluster`. To disable this behavior, +add the following to the Sidekiq configuration: ```ruby sidekiq['enable'] = true -sidekiq['cluster'] = true +sidekiq['cluster'] = false ``` -All of the aforementioned configuration options for `sidekiq_cluster` -are also available. By default, they will be configured as follows: +All of the aforementioned configuration options for `sidekiq` +are available. By default, they will be configured as follows: ```ruby sidekiq['experimental_queue_selector'] = false sidekiq['interval'] = nil -sidekiq['max_concurrency'] = nil +sidekiq['max_concurrency'] = 50 sidekiq['min_concurrency'] = nil sidekiq['negate'] = false sidekiq['queue_groups'] = ['*'] +sidekiq['shutdown_timeout'] = 25 ``` `sidekiq_cluster` must be disabled if you decide to configure the @@ -246,9 +249,9 @@ use all of its resources to perform those operations. To set up a separate 1. Edit `/etc/gitlab/gitlab.rb` and add: ```ruby - sidekiq_cluster['enable'] = true - sidekiq_cluster['negate'] = true - sidekiq_cluster['queue_groups'] = [ + sidekiq['enable'] = true + sidekiq['negate'] = true + sidekiq['queue_groups'] = [ "github_import_advance_stage", "github_importer:github_import_import_diff_note", "github_importer:github_import_import_issue", @@ -274,7 +277,7 @@ use all of its resources to perform those operations. To set up a separate ## Number of threads -Each process defined under `sidekiq_cluster` starts with a +Each process defined under `sidekiq` starts with a number of threads that equals the number of queues, plus one spare thread. For example, a process that handles the `process_commit` and `post_receive` queues will use three threads in total. @@ -290,11 +293,16 @@ latency and potentially cause client timeouts. See the [Sidekiq documentation about Redis](https://github.com/mperham/sidekiq/wiki/Using-Redis) for more details. -### When running a single Sidekiq process (default) +### When running a single Sidekiq process + +CAUTION: **Warning:** +Running Sidekiq directly is scheduled to be removed in GitLab +[14.0](https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/240). 1. Edit `/etc/gitlab/gitlab.rb` and add: ```ruby + sidekiq['cluster'] = false sidekiq['concurrency'] = 25 ``` @@ -306,13 +314,13 @@ details. This will set the concurrency (number of threads) for the Sidekiq process. -### When running Sidekiq cluster +### When running Sidekiq cluster (default) 1. Edit `/etc/gitlab/gitlab.rb` and add: ```ruby - sidekiq_cluster['min_concurrency'] = 15 - sidekiq_cluster['max_concurrency'] = 25 + sidekiq['min_concurrency'] = 15 + sidekiq['max_concurrency'] = 25 ``` 1. Save the file and reconfigure GitLab for the changes to take effect: @@ -344,7 +352,7 @@ To modify the check interval for the additional Sidekiq processes: 1. Edit `/etc/gitlab/gitlab.rb` and add: ```ruby - sidekiq_cluster['interval'] = 5 + sidekiq['interval'] = 5 ``` 1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb index 7e0398f09af..18f4cb559c5 100644 --- a/lib/gitlab/i18n.rb +++ b/lib/gitlab/i18n.rb @@ -5,28 +5,28 @@ module Gitlab extend self AVAILABLE_LANGUAGES = { + 'bg' => 'Bulgarian - български', + 'cs_CZ' => 'Czech - čeština', + 'de' => 'German - Deutsch', 'en' => 'English', - 'es' => 'Español', - 'gl_ES' => 'Galego', - 'de' => 'Deutsch', - 'fr' => 'Français', - 'pt_BR' => 'Português (Brasil)', - 'zh_CN' => '简体中文', - 'zh_HK' => '繁體中文 (香港)', - 'zh_TW' => '繁體中文 (臺灣)', - 'bg' => 'български', - 'ru' => 'Русский', - 'eo' => 'Esperanto', - 'it' => 'Italiano', - 'uk' => 'Українська', - 'ja' => '日本語', - 'ko' => '한국어', - 'nl_NL' => 'Nederlands', - 'tr_TR' => 'Türkçe', - 'id_ID' => 'Bahasa Indonesia', + 'eo' => 'Esperanto - esperanto', + 'es' => 'Spanish - español', 'fil_PH' => 'Filipino', - 'pl_PL' => 'Polski', - 'cs_CZ' => 'Čeština' + 'fr' => 'French - français', + 'gl_ES' => 'Galician - galego', + 'id_ID' => 'Indonesian - Bahasa Indonesia', + 'it' => 'Italian - italiano', + 'ja' => 'Japanese - 日本語', + 'ko' => 'Korean - 한국어', + 'nl_NL' => 'Dutch - Nederlands', + 'pl_PL' => 'Polish - polski', + 'pt_BR' => 'Portuguese (Brazil) - português (Brasil)', + 'ru' => 'Russian - Русский', + 'tr_TR' => 'Turkish - Türkçe', + 'uk' => 'Ukrainian - українська', + 'zh_CN' => 'Chinese, Simplified - 简体中文', + 'zh_HK' => 'Chinese, Traditional (Hong Kong) - 繁體中文 (香港)', + 'zh_TW' => 'Chinese, Traditional (Taiwan) - 繁體中文 (台灣)' }.freeze def available_locales diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 47e6a4d48ab..b607744fa51 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -2759,6 +2759,27 @@ msgstr "" msgid "AuditEvents|Target" msgstr "" +msgid "AuditLogs|(removed)" +msgstr "" + +msgid "AuditLogs|Action" +msgstr "" + +msgid "AuditLogs|Author" +msgstr "" + +msgid "AuditLogs|Date" +msgstr "" + +msgid "AuditLogs|IP Address" +msgstr "" + +msgid "AuditLogs|Object" +msgstr "" + +msgid "AuditLogs|Target" +msgstr "" + msgid "Aug" msgstr "" diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb index da286bb4092..8c3d01918fd 100644 --- a/spec/graphql/mutations/issues/update_spec.rb +++ b/spec/graphql/mutations/issues/update_spec.rb @@ -16,6 +16,8 @@ describe Mutations::Issues::Update do let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } let(:mutated_issue) { subject[:issue] } + specify { expect(described_class).to require_graphql_authorizations(:update_issue) } + describe '#resolve' do let(:mutation_params) do { diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb index c4ed99e56a0..7969cfd97b5 100644 --- a/spec/helpers/preferences_helper_spec.rb +++ b/spec/helpers/preferences_helper_spec.rb @@ -123,7 +123,7 @@ describe PreferencesHelper do describe '#language_choices' do it 'returns an array of all available languages' do expect(helper.language_choices).to be_an(Array) - expect(helper.language_choices.map(&:second)).to eq(Gitlab::I18n.available_locales) + expect(helper.language_choices.map(&:first)).to eq(Gitlab::I18n::AVAILABLE_LANGUAGES.values.sort) end end diff --git a/spec/services/spam/spam_action_service_spec.rb b/spec/services/spam/spam_action_service_spec.rb index 147b313dc1a..ff60eacc79d 100644 --- a/spec/services/spam/spam_action_service_spec.rb +++ b/spec/services/spam/spam_action_service_spec.rb @@ -78,7 +78,7 @@ describe Spam::SpamActionService do subject do described_service = described_class.new(spammable: issue, request: request) - described_service.execute(user_id: user.id, api: nil, recaptcha_verified: recaptcha_verified, spam_log_id: existing_spam_log.id) + described_service.execute(user: user, api: nil, recaptcha_verified: recaptcha_verified, spam_log_id: existing_spam_log.id) end before do diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb index 6439b68764e..3e2193a9069 100644 --- a/spec/support/matchers/graphql_matchers.rb +++ b/spec/support/matchers/graphql_matchers.rb @@ -1,8 +1,14 @@ # frozen_string_literal: true RSpec::Matchers.define :require_graphql_authorizations do |*expected| - match do |field| - expect(field.to_graphql.metadata[:authorize]).to eq(*expected) + match do |klass| + permissions = if klass.respond_to?(:required_permissions) + klass.required_permissions + else + [klass.to_graphql.metadata[:authorize]] + end + + expect(permissions).to eq(expected) end end |