From 52c7972910b960f37ae9792cb4d17876244d4bcf Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 30 Jul 2021 06:08:52 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../diffs/components/diff_file.vue | 2 + app/models/instance_configuration.rb | 59 +++++++++++++- .../help/instance_configuration.html.haml | 1 + .../_rate_limit_row.html.haml | 7 ++ .../_rate_limits.html.haml | 36 +++++++++ app/workers/all_queues.yml | 4 +- app/workers/gitlab_service_ping_worker.rb | 1 + .../namespaces/onboarding_progress_worker.rb | 1 + doc/user/admin_area/settings/help_page.md | 41 +++++++++- .../templates/Terraform.latest.gitlab-ci.yml | 5 ++ locale/gitlab.pot | 60 ++++++++++++++ .../pipeline/mr_event_rule_pipeline_spec.rb | 81 +++++++++++++++++++ .../diffs/components/diff_file_spec.js | 20 +++++ spec/models/instance_configuration_spec.rb | 54 +++++++++++++ 14 files changed, 368 insertions(+), 4 deletions(-) create mode 100644 app/views/help/instance_configuration/_rate_limit_row.html.haml create mode 100644 app/views/help/instance_configuration/_rate_limits.html.haml create mode 100644 qa/qa/specs/features/browser_ui/4_verify/pipeline/mr_event_rule_pipeline_spec.rb diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index be5f4b09c3e..b84d76ade45 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -205,6 +205,8 @@ export default { if (this.hasDiff) { this.postRender(); + } else if (this.viewDiffsFileByFile && !this.isCollapsed) { + this.requestDiff(); } this.manageViewedEffects(); diff --git a/app/models/instance_configuration.rb b/app/models/instance_configuration.rb index f401c23e453..29bf1b8ae5d 100644 --- a/app/models/instance_configuration.rb +++ b/app/models/instance_configuration.rb @@ -13,7 +13,8 @@ class InstanceConfiguration { ssh_algorithms_hashes: ssh_algorithms_hashes, host: host, gitlab_pages: gitlab_pages, - gitlab_ci: gitlab_ci }.deep_symbolize_keys + gitlab_ci: gitlab_ci, + rate_limits: rate_limits }.deep_symbolize_keys end end @@ -43,6 +44,50 @@ class InstanceConfiguration default: 100.megabytes }) end + def rate_limits + { + unauthenticated: { + enabled: application_settings[:throttle_unauthenticated_enabled], + requests_per_period: application_settings[:throttle_unauthenticated_requests_per_period], + period_in_seconds: application_settings[:throttle_unauthenticated_period_in_seconds] + }, + authenticated_api: { + enabled: application_settings[:throttle_authenticated_api_enabled], + requests_per_period: application_settings[:throttle_authenticated_api_requests_per_period], + period_in_seconds: application_settings[:throttle_authenticated_api_period_in_seconds] + }, + authenticated_web: { + enabled: application_settings[:throttle_authenticated_web_enabled], + requests_per_period: application_settings[:throttle_authenticated_web_requests_per_period], + period_in_seconds: application_settings[:throttle_authenticated_web_period_in_seconds] + }, + protected_paths: { + enabled: application_settings[:throttle_protected_paths_enabled], + requests_per_period: application_settings[:throttle_protected_paths_requests_per_period], + period_in_seconds: application_settings[:throttle_protected_paths_period_in_seconds] + }, + unauthenticated_packages_api: { + enabled: application_settings[:throttle_unauthenticated_packages_api_enabled], + requests_per_period: application_settings[:throttle_unauthenticated_packages_api_requests_per_period], + period_in_seconds: application_settings[:throttle_unauthenticated_packages_api_period_in_seconds] + }, + authenticated_packages_api: { + enabled: application_settings[:throttle_authenticated_packages_api_enabled], + requests_per_period: application_settings[:throttle_authenticated_packages_api_requests_per_period], + period_in_seconds: application_settings[:throttle_authenticated_packages_api_period_in_seconds] + }, + issue_creation: application_setting_limit_per_minute(:issues_create_limit), + note_creation: application_setting_limit_per_minute(:notes_create_limit), + project_export: application_setting_limit_per_minute(:project_export_limit), + project_export_download: application_setting_limit_per_minute(:project_download_export_limit), + project_import: application_setting_limit_per_minute(:project_import_limit), + group_export: application_setting_limit_per_minute(:group_export_limit), + group_export_download: application_setting_limit_per_minute(:group_download_export_limit), + group_import: application_setting_limit_per_minute(:group_import_limit), + raw_blob: application_setting_limit_per_minute(:raw_blob_request_limit) + } + end + def ssh_algorithm_file(algorithm) File.join(SSH_ALGORITHMS_PATH, "ssh_host_#{algorithm.downcase}_key.pub") end @@ -70,4 +115,16 @@ class InstanceConfiguration def ssh_algorithm_sha256(ssh_file_content) Gitlab::SSHPublicKey.new(ssh_file_content).fingerprint('SHA256') end + + def application_settings + Gitlab::CurrentSettings.current_application_settings + end + + def application_setting_limit_per_minute(setting) + { + enabled: application_settings[setting] > 0, + requests_per_period: application_settings[setting], + period_in_seconds: 1.minute + } + end end diff --git a/app/views/help/instance_configuration.html.haml b/app/views/help/instance_configuration.html.haml index 1cd05dcf65e..009fb24b1f8 100644 --- a/app/views/help/instance_configuration.html.haml +++ b/app/views/help/instance_configuration.html.haml @@ -8,6 +8,7 @@ = render 'help/instance_configuration/ssh_info' = render 'help/instance_configuration/gitlab_pages' = render 'help/instance_configuration/gitlab_ci' + = render 'help/instance_configuration/rate_limits' %p %strong= _("Table of contents") diff --git a/app/views/help/instance_configuration/_rate_limit_row.html.haml b/app/views/help/instance_configuration/_rate_limit_row.html.haml new file mode 100644 index 00000000000..85c165de7d4 --- /dev/null +++ b/app/views/help/instance_configuration/_rate_limit_row.html.haml @@ -0,0 +1,7 @@ +- public_visible = local_assigns.fetch(:public_visible, false) + +- if rate_limit && (public_visible || user_signed_in?) + %tr + %td= title + %td= instance_configuration_cell_html(rate_limit[:enabled] ? rate_limit[:requests_per_period] : nil) + %td= instance_configuration_cell_html(rate_limit[:enabled] ? rate_limit[:period_in_seconds] : nil) diff --git a/app/views/help/instance_configuration/_rate_limits.html.haml b/app/views/help/instance_configuration/_rate_limits.html.haml new file mode 100644 index 00000000000..d72bd845c5b --- /dev/null +++ b/app/views/help/instance_configuration/_rate_limits.html.haml @@ -0,0 +1,36 @@ +- rate_limits = @instance_configuration.settings[:rate_limits] +- content_for :table_content do + - if rate_limits + %li= link_to _('Rate Limits'), '#rate-limits' + +- content_for :settings_content do + - if rate_limits + %h2#rate-limits + = _('Rate Limits') + + %p + = _('There are several rate limits in place to protect the system.') + .table-responsive + %table + %thead + %tr + %th= _('Rate limit') + %th= _('Requests per period') + %th= _('Period in seconds') + %tbody + = render 'help/instance_configuration/rate_limit_row', title: _('Unauthenticated requests'), rate_limit: rate_limits[:unauthenticated], public_visible: true + = render 'help/instance_configuration/rate_limit_row', title: _('Authenticated API requests'), rate_limit: rate_limits[:authenticated_api] + = render 'help/instance_configuration/rate_limit_row', title: _('Authenticated web requests'), rate_limit: rate_limits[:authenticated_web] + = render 'help/instance_configuration/rate_limit_row', title: _('Protected Paths: requests'), rate_limit: rate_limits[:protected_paths] + = render 'help/instance_configuration/rate_limit_row', title: _('Package Registry: unauthenticated API requests'), rate_limit: rate_limits[:unauthenticated_packages_api], public_visible: true + = render 'help/instance_configuration/rate_limit_row', title: _('Package Registry: authenticated API requests'), rate_limit: rate_limits[:authenticated_packages_api] + = render 'help/instance_configuration/rate_limit_row', title: _('Issue creation requests'), rate_limit: rate_limits[:issue_creation] + = render 'help/instance_configuration/rate_limit_row', title: _('Note creation requests'), rate_limit: rate_limits[:note_creation] + = render 'help/instance_configuration/rate_limit_row', title: _('Project export requests'), rate_limit: rate_limits[:project_export] + = render 'help/instance_configuration/rate_limit_row', title: _('Project export download requests'), rate_limit: rate_limits[:project_export_download] + = render 'help/instance_configuration/rate_limit_row', title: _('Project import requests'), rate_limit: rate_limits[:project_import] + = render 'help/instance_configuration/rate_limit_row', title: _('Group export requests'), rate_limit: rate_limits[:group_export] + = render 'help/instance_configuration/rate_limit_row', title: _('Group export download requests'), rate_limit: rate_limits[:group_export_download] + = render 'help/instance_configuration/rate_limit_row', title: _('Group import requests'), rate_limit: rate_limits[:group_import] + = render 'help/instance_configuration/rate_limit_row', title: _('Raw blob requests'), rate_limit: rate_limits[:raw_blob] + %br diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 222d83aa4a1..4c64ccb259c 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -288,7 +288,7 @@ :feature_category: :service_ping :has_external_dependencies: :urgency: :low - :resource_boundary: :unknown + :resource_boundary: :cpu :weight: 1 :idempotent: :tags: [] @@ -2383,7 +2383,7 @@ :feature_category: :product_analytics :has_external_dependencies: :urgency: :low - :resource_boundary: :unknown + :resource_boundary: :cpu :weight: 1 :idempotent: true :tags: diff --git a/app/workers/gitlab_service_ping_worker.rb b/app/workers/gitlab_service_ping_worker.rb index a6ff4ecc092..6cf46458b1e 100644 --- a/app/workers/gitlab_service_ping_worker.rb +++ b/app/workers/gitlab_service_ping_worker.rb @@ -11,6 +11,7 @@ class GitlabServicePingWorker # rubocop:disable Scalability/IdempotentWorker include Gitlab::ExclusiveLeaseHelpers feature_category :service_ping + worker_resource_boundary :cpu sidekiq_options retry: 3, dead: false sidekiq_retry_in { |count| (count + 1) * 8.hours.to_i } diff --git a/app/workers/namespaces/onboarding_progress_worker.rb b/app/workers/namespaces/onboarding_progress_worker.rb index ea49ff28f26..43d13618091 100644 --- a/app/workers/namespaces/onboarding_progress_worker.rb +++ b/app/workers/namespaces/onboarding_progress_worker.rb @@ -9,6 +9,7 @@ module Namespaces sidekiq_options retry: 3 feature_category :product_analytics + worker_resource_boundary :cpu tags :exclude_from_kubernetes urgency :low diff --git a/doc/user/admin_area/settings/help_page.md b/doc/user/admin_area/settings/help_page.md index d2f99a51ec3..f79c9e58162 100644 --- a/doc/user/admin_area/settings/help_page.md +++ b/doc/user/admin_area/settings/help_page.md @@ -8,7 +8,7 @@ type: howto # Customize the Help and sign-in page messages In large organizations, it is useful to have information about who to contact or where -to go for help. You can customize and display this information on the GitLab `/help` page and on +to go for help. You can customize and display this information on the GitLab `/help` page and on the GitLab sign-in page. ## Add a help message to the Help page @@ -58,6 +58,45 @@ You can specify a custom URL to which users are directed when they: 1. Enter the URL in the **Support page URL** field. 1. Select **Save changes**. +## Redirect GitLab documentation links + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43157) in GitLab 13.5. +> - [Deployed behind a feature flag](../../feature_flags.md), disabled by default. +> - Enabled on GitLab.com. +> - Ready for production use. +> - To use in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-or-disable-gitlab-documentation-link-redirects). **(FREE SELF)** + +This in-development feature might not be available for your use. There can be +[risks when enabling features still in development](../../feature_flags.md#risks-when-enabling-features-still-in-development). +Refer to this feature's version history for more details. + +Documentation links go to the `/help` section on the instance by default, but you can +redirect these links to an external documentation site like `https://docs.gitlab.com`: + +1. On the top bar, select **Menu >** **{admin}** **Admin**. +1. In the left sidebar, select **Settings > Preferences**, then expand **Help page**. +1. Enter the URL in the **Documentation pages URL** field. +1. Select **Save changes**. + +### Enable or disable GitLab documentation link redirects **(FREE SELF)** + +The GitLab documentation link redirects feature is under development and not ready +for production use. It is deployed behind a feature flag that is **disabled by default**. +[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md) +can enable it. + +To enable it: + +```ruby +Feature.enable(:help_page_documentation_redirect) +``` + +To disable it: + +```ruby +Feature.disable(:help_page_documentation_redirect) +``` +