From 7e8ecb5c00aae3b7072a5b8ff2c53db03c0bc579 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 2 Jun 2023 09:07:27 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../javascripts/blob/file_template_mediator.js | 2 - .../metrics_dashboard_selector.js | 29 ------- .../ide/stores/modules/file_templates/getters.js | 4 - app/assets/stylesheets/page_bundles/editor.scss | 3 +- app/finders/template_finder.rb | 1 - app/helpers/blob_helper.rb | 4 - app/models/user.rb | 9 ++- .../projects/blob/_template_selectors.html.haml | 2 - doc/administration/auth/jwt.md | 3 + doc/administration/geo/index.md | 5 +- .../geo/replication/object_storage.md | 2 +- doc/administration/geo/setup/index.md | 4 +- doc/api/groups.md | 26 +++++++ doc/api/users.md | 14 ++++ .../ci_pipeline_components/img/catalogs.png | Bin 102551 -> 30325 bytes .../documentation/styleguide/word_list.md | 4 + .../settings/instance_template_repository.md | 4 - doc/user/application_security/api_fuzzing/index.md | 8 -- .../application_security/secret_detection/index.md | 5 +- doc/user/img/explain_this_vulnerability.png | Bin 371791 -> 120342 bytes doc/user/packages/generic_packages/index.md | 4 +- lib/api/admin/batched_background_migrations.rb | 7 +- lib/api/project_templates.rb | 8 +- lib/gitlab/database/each_database.rb | 1 + lib/gitlab/database/partitioning.rb | 2 +- locale/gitlab.pot | 33 +++++--- spec/finders/template_finder_spec.rb | 13 ---- .../stores/modules/file_templates/getters_spec.js | 2 +- .../jobs/components/table/job_table_app_spec.js | 46 ++++------- spec/lib/gitlab/database/partitioning_spec.rb | 18 +++++ .../admin/batched_background_migrations_spec.rb | 21 ++++++ spec/requests/api/project_templates_spec.rb | 45 ----------- spec/services/submodules/update_service_spec.rb | 84 --------------------- 33 files changed, 153 insertions(+), 260 deletions(-) delete mode 100644 app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js diff --git a/app/assets/javascripts/blob/file_template_mediator.js b/app/assets/javascripts/blob/file_template_mediator.js index 7ccb66f18a9..e0ecfca75f5 100644 --- a/app/assets/javascripts/blob/file_template_mediator.js +++ b/app/assets/javascripts/blob/file_template_mediator.js @@ -10,7 +10,6 @@ import BlobCiYamlSelector from './template_selectors/ci_yaml_selector'; import DockerfileSelector from './template_selectors/dockerfile_selector'; import GitignoreSelector from './template_selectors/gitignore_selector'; import LicenseSelector from './template_selectors/license_selector'; -import MetricsDashboardSelector from './template_selectors/metrics_dashboard_selector'; export default class FileTemplateMediator { constructor({ editor, currentAction, projectId }) { @@ -30,7 +29,6 @@ export default class FileTemplateMediator { this.templateSelectors = [ GitignoreSelector, BlobCiYamlSelector, - MetricsDashboardSelector, DockerfileSelector, LicenseSelector, ].map((TemplateSelectorClass) => new TemplateSelectorClass({ mediator: this })); diff --git a/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js b/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js deleted file mode 100644 index 8b10b02ae1d..00000000000 --- a/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js +++ /dev/null @@ -1,29 +0,0 @@ -import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; -import FileTemplateSelector from '../file_template_selector'; - -export default class MetricsDashboardSelector extends FileTemplateSelector { - constructor({ mediator }) { - super(mediator); - this.config = { - key: 'metrics-dashboard-yaml', - name: '.metrics-dashboard.yml', - pattern: /(.metrics-dashboard.yml)/, - type: 'metrics_dashboard_ymls', - dropdown: '.js-metrics-dashboard-selector', - wrapper: '.js-metrics-dashboard-selector-wrap', - }; - } - - initDropdown() { - initDeprecatedJQueryDropdown(this.$dropdown, { - data: this.$dropdown.data('data'), - filterable: true, - selectable: true, - search: { - fields: ['name'], - }, - clicked: (options) => this.reportSelectionName(options), - text: (item) => item.name, - }); - } -} diff --git a/app/assets/javascripts/ide/stores/modules/file_templates/getters.js b/app/assets/javascripts/ide/stores/modules/file_templates/getters.js index 9708e5e588c..bf0d3ed337c 100644 --- a/app/assets/javascripts/ide/stores/modules/file_templates/getters.js +++ b/app/assets/javascripts/ide/stores/modules/file_templates/getters.js @@ -18,10 +18,6 @@ export const templateTypes = () => [ name: __('Dockerfile'), key: 'dockerfiles', }, - { - name: '.metrics-dashboard.yml', - key: 'metrics_dashboard_ymls', - }, ]; export const showFileTemplatesBar = (_, getters, rootState) => (name) => diff --git a/app/assets/stylesheets/page_bundles/editor.scss b/app/assets/stylesheets/page_bundles/editor.scss index a1165279bc4..55fffad4a0e 100644 --- a/app/assets/stylesheets/page_bundles/editor.scss +++ b/app/assets/stylesheets/page_bundles/editor.scss @@ -170,8 +170,7 @@ .license-selector, .gitignore-selector, .gitlab-ci-yml-selector, - .dockerfile-selector, - .metrics-dashboard-selector { + .dockerfile-selector { display: inline-block; vertical-align: top; font-family: $regular_font; diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb index c6c5c30cbf7..c9b5711949f 100644 --- a/app/finders/template_finder.rb +++ b/app/finders/template_finder.rb @@ -7,7 +7,6 @@ class TemplateFinder dockerfiles: ::Gitlab::Template::DockerfileTemplate, gitignores: ::Gitlab::Template::GitignoreTemplate, gitlab_ci_ymls: ::Gitlab::Template::GitlabCiYmlTemplate, - metrics_dashboard_ymls: ::Gitlab::Template::MetricsDashboardTemplate, issues: ::Gitlab::Template::IssueTemplate, merge_requests: ::Gitlab::Template::MergeRequestTemplate ).freeze diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 02f69327dff..be9306ce80b 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -141,10 +141,6 @@ module BlobHelper @gitlab_ci_ymls ||= TemplateFinder.all_template_names(project, :gitlab_ci_ymls) end - def metrics_dashboard_ymls(project) - @metrics_dashboard_ymls ||= TemplateFinder.all_template_names(project, :metrics_dashboard_ymls) - end - def dockerfile_names(project) @dockerfile_names ||= TemplateFinder.all_template_names(project, :dockerfiles) end diff --git a/app/models/user.rb b/app/models/user.rb index 0fbbce1c36e..714c449ffd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1666,9 +1666,7 @@ class User < ApplicationRecord DELETION_DELAY_IN_DAYS = 7.days def delete_async(deleted_by:, params: {}) - is_deleting_own_record = deleted_by.id == id - - if is_deleting_own_record && ::Feature.enabled?(:delay_delete_own_user) + if should_delay_delete?(deleted_by) new_note = format(_("User deleted own account on %{timestamp}"), timestamp: Time.zone.now) self.note = "#{new_note}\n#{note}".strip @@ -2351,6 +2349,11 @@ class User < ApplicationRecord ban end + def should_delay_delete?(deleted_by) + is_deleting_own_record = deleted_by.id == id + is_deleting_own_record && ::Feature.enabled?(:delay_delete_own_user) + end + def pbkdf2? return false unless otp_backup_codes&.any? diff --git a/app/views/projects/blob/_template_selectors.html.haml b/app/views/projects/blob/_template_selectors.html.haml index c1f4633f69f..0bd29ceb563 100644 --- a/app/views/projects/blob/_template_selectors.html.haml +++ b/app/views/projects/blob/_template_selectors.html.haml @@ -4,8 +4,6 @@ = dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-license-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: licenses_for_select(@project), project: @project.name, fullname: @project.namespace.human_name, qa_selector: 'license_dropdown' } }) .gitignore-selector.js-gitignore-selector-wrap.js-template-selector-wrap.hidden = dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-gitignore-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitignore_names(@project), qa_selector: 'gitignore_dropdown' } }) - .metrics-dashboard-selector.js-metrics-dashboard-selector-wrap.js-template-selector-wrap.hidden - = dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-metrics-dashboard-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: metrics_dashboard_ymls(@project), qa_selector: 'metrics_dashboard_dropdown' } }) #gitlab-ci-yml-selector.gitlab-ci-yml-selector.js-gitlab-ci-yml-selector-wrap.js-template-selector-wrap.hidden = dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-gitlab-ci-yml-selector', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitlab_ci_ymls(@project), selected: params[:template], qa_selector: 'gitlab_ci_yml_dropdown' } }) .dockerfile-selector.js-dockerfile-selector-wrap.js-template-selector-wrap.hidden diff --git a/doc/administration/auth/jwt.md b/doc/administration/auth/jwt.md index 9994b374038..bdcd6fc89cc 100644 --- a/doc/administration/auth/jwt.md +++ b/doc/administration/auth/jwt.md @@ -70,6 +70,9 @@ JWT provides you with a secret key for you to use. For more information on each configuration option refer to the [OmniAuth JWT usage documentation](https://github.com/mbleigh/omniauth-jwt#usage). + WARNING: + Incorrectly configuring these settings can result in an insecure instance. + 1. Change `YOUR_APP_SECRET` to the client secret and set `auth_url` to your redirect URL. 1. Save the configuration file. 1. For the changes to take effect: diff --git a/doc/administration/geo/index.md b/doc/administration/geo/index.md index 31de7f5c62f..be12ec97441 100644 --- a/doc/administration/geo/index.md +++ b/doc/administration/geo/index.md @@ -199,7 +199,8 @@ This list of limitations only reflects the latest version of GitLab. If you are - [Pages access control](../../user/project/pages/pages_access_control.md) doesn't work on secondaries. See [GitLab issue #9336](https://gitlab.com/gitlab-org/gitlab/-/issues/9336) for details. - [GitLab chart with Geo](https://docs.gitlab.com/charts/advanced/geo/) does not support [Unified URLs](secondary_proxy/index.md#set-up-a-unified-url-for-geo-sites). See [GitLab issue #3522](https://gitlab.com/gitlab-org/charts/gitlab/-/issues/3522) for more details. - [Disaster recovery](disaster_recovery/index.md) for multi-secondary sites causes downtime due to the complete re-synchronization and re-configuration of all non-promoted secondaries. -- For Git over SSH, secondary sites must use the same port as the primary. [GitLab issue #339262](https://gitlab.com/gitlab-org/gitlab/-/issues/339262) proposes to remove this limitation. +- For Git over SSH, to make the project clone URL display correctly regardless of which site you are browsing, secondary sites must use the same port as the primary. [GitLab issue #339262](https://gitlab.com/gitlab-org/gitlab/-/issues/339262) proposes to remove this limitation. +- Git push over SSH against a secondary site does not work for pushes over 1.86 GB. [GitLab issue #413109](https://gitlab.com/gitlab-org/gitlab/-/issues/413109) tracks this bug. ### Limitations on replication/verification @@ -275,7 +276,7 @@ For information on configuring Geo for multiple nodes, see [Geo for multiple ser ### Configuring Geo with Object Storage -For information on configuring Geo with object storage, see [Geo with Object storage](replication/object_storage.md). +For information on configuring Geo with Object storage, see [Geo with Object storage](replication/object_storage.md). ### Disaster Recovery diff --git a/doc/administration/geo/replication/object_storage.md b/doc/administration/geo/replication/object_storage.md index 8128eaf5310..b39acf2466d 100644 --- a/doc/administration/geo/replication/object_storage.md +++ b/doc/administration/geo/replication/object_storage.md @@ -9,7 +9,7 @@ type: howto Geo can be used in combination with Object Storage (AWS S3, or other compatible object storage). -Currently, **secondary** sites can use either: +**Secondary** sites can use one of the following: - The same storage bucket as the **primary** site. - A replicated storage bucket. diff --git a/doc/administration/geo/setup/index.md b/doc/administration/geo/setup/index.md index 20661aead5f..3f3a5c29e78 100644 --- a/doc/administration/geo/setup/index.md +++ b/doc/administration/geo/setup/index.md @@ -18,8 +18,8 @@ type: howto - Ensure the **primary** site has a [GitLab Premium or Ultimate](https://about.gitlab.com/pricing/) subscription to unlock Geo. You only need one license for all the sites. - Confirm the [requirements for running Geo](../index.md#requirements-for-running-geo) are met by all sites. For example, sites must use the same GitLab version, and sites must be able to communicate with each other over certain ports. -- Confirm the **primary** and **secondary** site storage configurations match. If the primary Geo site uses object storage, the secondary Geo site must use it too. See [Geo with Object storage] (../replication/object_storage.md) for more details. -- Ensure clocks are synchronized between the **primary** site and the **secondary** site. Synchronized clocks are required for Geo to function correctly. For example, if the clock drift between the **primary** and **secondary** sites exceeds 1 minute, replication will fail. +- Confirm the **primary** and **secondary** site storage configurations match. If the primary Geo site uses object storage, the secondary Geo site must use it too. For more information, see [Geo with Object storage](../replication/object_storage.md). +- Ensure clocks are synchronized between the **primary** site and the **secondary** site. Synchronized clocks are required for Geo to function correctly. For example, if the clock drift between the **primary** and **secondary** sites exceeds 1 minute, replication fails. ## Using Omnibus GitLab diff --git a/doc/api/groups.md b/doc/api/groups.md index 9b683ca8e1c..91c6611f62d 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -1269,6 +1269,32 @@ Example response: ] ``` +## Service Accounts **(PREMIUM)** + +### Create Service Account User + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/407775) in GitLab 16.1. + +Creates a service account user with an auto-generated email address and username. + +```plaintext +POST /groups/:id/service_accounts +``` + +```shell +curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/345/service_accounts" +``` + +Example response: + +```json +{ + "id": 57, + "username": "service_account_group_345_6018816a18e515214e0c34c2b33523fc", + "name": "Service account user" +} +``` + ## Hooks **(PREMIUM)** Also called Group Hooks and Webhooks. diff --git a/doc/api/users.md b/doc/api/users.md index 809d1474803..a69bae1c2cf 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -992,6 +992,20 @@ Example response: } ``` +## Create Service Account User **(PREMIUM)** + +> Ability to create a service account user was [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/406782) in GitLab 16.1 + +Creates a service account user with an auto-generated email address and username. + +```plaintext +POST /service_accounts +``` + +```shell +curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/service_accounts" +``` + ## List user projects See the [list of user projects](projects.md#list-user-projects). diff --git a/doc/architecture/blueprints/ci_pipeline_components/img/catalogs.png b/doc/architecture/blueprints/ci_pipeline_components/img/catalogs.png index 9353c5266e5..8c83aede186 100644 Binary files a/doc/architecture/blueprints/ci_pipeline_components/img/catalogs.png and b/doc/architecture/blueprints/ci_pipeline_components/img/catalogs.png differ diff --git a/doc/development/documentation/styleguide/word_list.md b/doc/development/documentation/styleguide/word_list.md index 8a08fcd0cc8..83efbc5ab15 100644 --- a/doc/development/documentation/styleguide/word_list.md +++ b/doc/development/documentation/styleguide/word_list.md @@ -128,6 +128,10 @@ The token generated when you create an agent for Kubernetes. Use **agent access - secret token - authentication token +## AI, artificial intelligence + +Use **AI**. Do not spell out **artificial intelligence**. + ## air gap, air-gapped Use **offline environment** to describe installations that have physical barriers or security policies that prevent or limit internet access. Do not use **air gap**, **air gapped**, or **air-gapped**. For example: diff --git a/doc/user/admin_area/settings/instance_template_repository.md b/doc/user/admin_area/settings/instance_template_repository.md index 026782ae83b..dc80fd88820 100644 --- a/doc/user/admin_area/settings/instance_template_repository.md +++ b/doc/user/admin_area/settings/instance_template_repository.md @@ -43,7 +43,6 @@ are supported: | `.gitignore` | `gitignore` | `.gitignore` | | `.gitlab-ci.yml` | `gitlab-ci` | `.yml` | | `LICENSE` | `LICENSE` | `.txt` | -| `metrics-dashboard.yml` | `metrics-dashboards` | `.yml` | Each template must go in its respective subdirectory, have the correct extension and not be empty. So, the hierarchy should look like this: @@ -62,9 +61,6 @@ extension and not be empty. So, the hierarchy should look like this: |-- LICENSE |-- custom_license.txt |-- another_license.txt -|-- metrics-dashboards - |-- custom_metrics-dashboard.yml - |-- another_metrics-dashboard.yml ``` Your custom templates are displayed on the dropdown list when a new file is added through the GitLab UI: diff --git a/doc/user/application_security/api_fuzzing/index.md b/doc/user/application_security/api_fuzzing/index.md index b613b0cc33e..46f6dd63d3f 100644 --- a/doc/user/application_security/api_fuzzing/index.md +++ b/doc/user/application_security/api_fuzzing/index.md @@ -2606,14 +2606,6 @@ deploy-test-target: - environment_url.txt ``` - - ### Use OpenAPI with an invalid schema There are cases where the document is autogenerated with an invalid schema or cannot be edited manually in a timely manner. In those scenarios, the API Fuzzing is able to perform a relaxed validation by setting the variable `FUZZAPI_OPENAPI_RELAXED_VALIDATION`. We recommend providing a fully compliant OpenAPI document to prevent unexpected behaviors. diff --git a/doc/user/application_security/secret_detection/index.md b/doc/user/application_security/secret_detection/index.md index 1f07e9a5eb7..be89fbc6800 100644 --- a/doc/user/application_security/secret_detection/index.md +++ b/doc/user/application_security/secret_detection/index.md @@ -107,7 +107,8 @@ Secret Detection can detect if a secret was added in one commit and removed in a In a merge request, Secret Detection scans every commit made on the source branch. To use this feature, you must use the [`latest` Secret Detection template](#templates), as it supports - [merge request pipelines](../../../ci/pipelines/merge_request_pipelines.md). + [merge request pipelines](../../../ci/pipelines/merge_request_pipelines.md). Secret Detection's + results are only available after the pipeline is completed. ## Templates @@ -116,7 +117,7 @@ provided with GitLab upgrades, allowing you to benefit from any improvements and Available templates: -- [`Secret-Detection.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml): Stable version of the Secret Detection CI/CD template. +- [`Secret-Detection.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml): Stable, default version of the Secret Detection CI/CD template. - [`Secret-Detection.latest.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.latest.gitlab-ci.yml): Latest version of the Secret Detection template. WARNING: diff --git a/doc/user/img/explain_this_vulnerability.png b/doc/user/img/explain_this_vulnerability.png index 0880ad5f875..bb938241911 100644 Binary files a/doc/user/img/explain_this_vulnerability.png and b/doc/user/img/explain_this_vulnerability.png differ diff --git a/doc/user/packages/generic_packages/index.md b/doc/user/packages/generic_packages/index.md index e6ee4caa5d4..d24808674dc 100644 --- a/doc/user/packages/generic_packages/index.md +++ b/doc/user/packages/generic_packages/index.md @@ -225,12 +225,12 @@ If you are receiving `HTTP 500: Internal Server Error` responses when publishing # Consolidated Object Storage settings gitlab_rails['object_store']['connection'] = { # Other connection settings - `aws_signature_version` => '4' + 'aws_signature_version' => '4' } # OR # Storage-specific form settings gitlab_rails['packages_object_store_connection'] = { # Other connection settings - `aws_signature_version` => '4' + 'aws_signature_version' => '4' } ``` diff --git a/lib/api/admin/batched_background_migrations.rb b/lib/api/admin/batched_background_migrations.rb index 7e612b5b66a..c0d1ce8767d 100644 --- a/lib/api/admin/batched_background_migrations.rb +++ b/lib/api/admin/batched_background_migrations.rb @@ -142,9 +142,12 @@ module API @base_model ||= Gitlab::Database.database_base_models[database] end + # Force progress evaluation to occur now while we're using the right connection def present_entity(result) - present result, - with: ::API::Entities::BatchedBackgroundMigration + representation = entity_representation_for(::API::Entities::BatchedBackgroundMigration, result, {}) + json_representation = Gitlab::Json.dump(representation) + + body Gitlab::Json::PrecompiledJson.new(json_representation) end end end diff --git a/lib/api/project_templates.rb b/lib/api/project_templates.rb index 2360a7e6b2a..49e2e4d8a91 100644 --- a/lib/api/project_templates.rb +++ b/lib/api/project_templates.rb @@ -4,7 +4,7 @@ module API class ProjectTemplates < ::API::Base include PaginationParams - TEMPLATE_TYPES = %w[dockerfiles gitignores gitlab_ci_ymls licenses metrics_dashboard_ymls issues merge_requests].freeze + TEMPLATE_TYPES = %w[dockerfiles gitignores gitlab_ci_ymls licenses issues merge_requests].freeze # The regex is needed to ensure a period (e.g. agpl-3.0) # isn't confused with a format type. We also need to allow encoded # values (e.g. C%2B%2B for C++), so allow % and + as well. @@ -16,7 +16,7 @@ module API params do requires :id, types: [String, Integer], desc: 'The ID or URL-encoded path of the project' - requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|metrics_dashboard_ymls|issues|merge_requests) of the template' + requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses|issues|merge_requests) of the template' end resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do desc 'Get a list of templates available to this project' do @@ -32,8 +32,6 @@ module API use :pagination end get ':id/templates/:type' do - bad_request! if params[:type] == 'metrics_dashboard_ymls' && Feature.enabled?(:remove_monitor_metrics) - templates = TemplateFinder.all_template_names(user_project, params[:type]).values.flatten present paginate(::Kaminari.paginate_array(templates)), with: Entities::TemplatesList @@ -62,8 +60,6 @@ module API end get ':id/templates/:type/:name', requirements: TEMPLATE_NAMES_ENDPOINT_REQUIREMENTS do - bad_request! if params[:type] == 'metrics_dashboard_ymls' && Feature.enabled?(:remove_monitor_metrics) - begin template = TemplateFinder.build( params[:type], diff --git a/lib/gitlab/database/each_database.rb b/lib/gitlab/database/each_database.rb index 02f008abf85..b1af62e4875 100644 --- a/lib/gitlab/database/each_database.rb +++ b/lib/gitlab/database/each_database.rb @@ -18,6 +18,7 @@ module Gitlab end end end + alias_method :each_db_connection, :each_database_connection def each_model_connection(models, only_on: nil, &blk) selected_databases = Array.wrap(only_on).map(&:to_sym) diff --git a/lib/gitlab/database/partitioning.rb b/lib/gitlab/database/partitioning.rb index 5d507342ee0..9895a68ec8d 100644 --- a/lib/gitlab/database/partitioning.rb +++ b/lib/gitlab/database/partitioning.rb @@ -40,7 +40,7 @@ module Gitlab next if model < ::Gitlab::Database::SharedModel && !(model < TableWithoutModel) model_connection_name = model.connection_db_config.name - Gitlab::Database::EachDatabase.each_database_connection do |connection, connection_name| + Gitlab::Database::EachDatabase.each_db_connection(include_shared: false) do |connection, connection_name| if connection_name != model_connection_name PartitionManager.new(model, connection: connection).sync_partitions end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 5ca3fa757dc..3258260f921 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1110,6 +1110,30 @@ msgstr "" msgid "%{start} to %{end}" msgstr "" +msgid "%{statusStart}Dismissed%{statusEnd}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd} at %{projectLink}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd} on pipeline %{pipelineLink}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd} on pipeline %{pipelineLink} at %{projectLink}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} at %{projectLink}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} on pipeline %{pipelineLink}" +msgstr "" + +msgid "%{statusStart}Dismissed%{statusEnd}: %{dismissalReason} on pipeline %{pipelineLink} at %{projectLink}" +msgstr "" + msgid "%{strongOpen}Warning:%{strongClose} SAML group links can cause GitLab to automatically remove members from groups." msgstr "" @@ -16095,15 +16119,6 @@ msgstr "" msgid "Dismissed" msgstr "" -msgid "Dismissed at %{projectLink}" -msgstr "" - -msgid "Dismissed on pipeline %{pipelineLink}" -msgstr "" - -msgid "Dismissed on pipeline %{pipelineLink} at %{projectLink}" -msgstr "" - msgid "Display" msgstr "" diff --git a/spec/finders/template_finder_spec.rb b/spec/finders/template_finder_spec.rb index c466f533a61..c2b42cf0eb3 100644 --- a/spec/finders/template_finder_spec.rb +++ b/spec/finders/template_finder_spec.rb @@ -20,7 +20,6 @@ RSpec.describe TemplateFinder do :dockerfiles | 'Binary' :gitignores | 'Actionscript' :gitlab_ci_ymls | 'Android' - :metrics_dashboard_ymls | 'Default' end with_them do @@ -112,7 +111,6 @@ RSpec.describe TemplateFinder do :gitignores | described_class :gitlab_ci_ymls | described_class :licenses | ::LicenseTemplateFinder - :metrics_dashboard_ymls | described_class :issues | described_class :merge_requests | described_class end @@ -123,16 +121,6 @@ RSpec.describe TemplateFinder do it { is_expected.to be_a(expected_class) } it { expect(finder.project).to eq(project) } end - - context 'when metrics dashboard is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - subject(:finder) { described_class.build(:metrics_dashboard_ymls, project) } - - it { is_expected.to be_nil } - end end describe '#execute' do @@ -178,7 +166,6 @@ RSpec.describe TemplateFinder do :dockerfiles | 'Binary' :gitignores | 'Actionscript' :gitlab_ci_ymls | 'Android' - :metrics_dashboard_ymls | 'Default' end with_them do diff --git a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js index e237b167f96..02e0d55346e 100644 --- a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js @@ -5,7 +5,7 @@ import createState from '~/ide/stores/state'; describe('IDE file templates getters', () => { describe('templateTypes', () => { it('returns list of template types', () => { - expect(getters.templateTypes().length).toBe(5); + expect(getters.templateTypes().length).toBe(4); }); }); diff --git a/spec/frontend/jobs/components/table/job_table_app_spec.js b/spec/frontend/jobs/components/table/job_table_app_spec.js index 0e59e9ab5b6..032b83ca22b 100644 --- a/spec/frontend/jobs/components/table/job_table_app_spec.js +++ b/spec/frontend/jobs/components/table/job_table_app_spec.js @@ -60,14 +60,8 @@ describe('Job table app', () => { handler = successHandler, countHandler = countSuccessHandler, mountFn = shallowMount, - data = {}, } = {}) => { wrapper = mountFn(JobsTableApp, { - data() { - return { - ...data, - }; - }, provide: { fullPath: projectPath, }, @@ -108,34 +102,28 @@ describe('Job table app', () => { }); it('should refetch jobs query on fetchJobsByStatus event', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findTabs().vm.$emit('fetchJobsByStatus'); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1); + expect(successHandler).toHaveBeenCalledTimes(2); }); it('avoids refetch jobs query when scope has not changed', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findTabs().vm.$emit('fetchJobsByStatus', null); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); }); it('should refetch jobs count query when the amount jobs and count do not match', async () => { - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); // after applying filter a new count is fetched findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(2); // tab is switched to `finished`, no count await findTabs().vm.$emit('fetchJobsByStatus', ['FAILED', 'SUCCESS', 'CANCELED']); @@ -143,7 +131,7 @@ describe('Job table app', () => { // tab is switched back to `all`, the old filter count has to be overwritten with new count await findTabs().vm.$emit('fetchJobsByStatus', null); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(2); + expect(countSuccessHandler).toHaveBeenCalledTimes(3); }); describe('when infinite scrolling is triggered', () => { @@ -261,25 +249,21 @@ describe('Job table app', () => { it('refetches jobs query when filtering', async () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(1); + expect(successHandler).toHaveBeenCalledTimes(2); }); it('refetches jobs count query when filtering', async () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); - - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', [mockFailedSearchToken]); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(2); }); it('shows raw text warning when user inputs raw text', async () => { @@ -292,14 +276,14 @@ describe('Job table app', () => { createComponent(); - jest.spyOn(wrapper.vm.$apollo.queries.jobs, 'refetch').mockImplementation(jest.fn()); - jest.spyOn(wrapper.vm.$apollo.queries.jobsCount, 'refetch').mockImplementation(jest.fn()); + expect(successHandler).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); await findFilteredSearch().vm.$emit('filterJobsBySearch', ['raw text']); expect(createAlert).toHaveBeenCalledWith(expectedWarning); - expect(wrapper.vm.$apollo.queries.jobs.refetch).toHaveBeenCalledTimes(0); - expect(wrapper.vm.$apollo.queries.jobsCount.refetch).toHaveBeenCalledTimes(0); + expect(successHandler).toHaveBeenCalledTimes(1); + expect(countSuccessHandler).toHaveBeenCalledTimes(1); }); it('updates URL query string when filtering jobs by status', async () => { diff --git a/spec/lib/gitlab/database/partitioning_spec.rb b/spec/lib/gitlab/database/partitioning_spec.rb index e654cb65452..8724716dd3d 100644 --- a/spec/lib/gitlab/database/partitioning_spec.rb +++ b/spec/lib/gitlab/database/partitioning_spec.rb @@ -112,6 +112,24 @@ RSpec.describe Gitlab::Database::Partitioning, feature_category: :database do end end + context 'without ci database' do + it 'only creates partitions for main database' do + skip_if_database_exists(:ci) + + allow(Gitlab::Database::Partitioning::PartitionManager).to receive(:new).and_call_original + + # Also, in the case where `ci` database is shared with `main` database, + # check that we do not run PartitionManager again for ci connection as + # that is redundant. + expect(Gitlab::Database::Partitioning::PartitionManager).not_to receive(:new) + .with(anything, connection: ci_connection).and_call_original + + expect { described_class.sync_partitions(models) } + .to change { find_partitions(table_names.first, conn: main_connection).size }.from(0) + .and change { find_partitions(table_names.last, conn: main_connection).size }.from(0) + end + end + context 'when no partitioned models are given' do it 'manages partitions for each registered model' do described_class.register_models([models.first]) diff --git a/spec/requests/api/admin/batched_background_migrations_spec.rb b/spec/requests/api/admin/batched_background_migrations_spec.rb index e88fba3fbe7..180b6c7abd6 100644 --- a/spec/requests/api/admin/batched_background_migrations_spec.rb +++ b/spec/requests/api/admin/batched_background_migrations_spec.rb @@ -50,6 +50,27 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations, feature_category: :datab show_migration end + + context 'when migration has completed jobs' do + let(:migration) do + Gitlab::Database::SharedModel.using_connection(ci_model.connection) do + create(:batched_background_migration, :active, total_tuple_count: 100) + end + end + + let!(:batched_job) do + Gitlab::Database::SharedModel.using_connection(ci_model.connection) do + create(:batched_background_migration_job, :succeeded, batched_migration: migration, batch_size: 8) + end + end + + it 'calculates the progress using the CI database' do + show_migration + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['progress']).to eq(8) + end + end end context 'when the database name does not exist' do diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb index 91e5ed76c37..e1d156afd54 100644 --- a/spec/requests/api/project_templates_spec.rb +++ b/spec/requests/api/project_templates_spec.rb @@ -63,27 +63,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management expect(json_response).to satisfy_one { |template| template['key'] == 'mit' } end - it 'returns metrics_dashboard_ymls' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls") - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to include_pagination_headers - expect(response).to match_response_schema('public_api/v4/template_list') - expect(json_response).to satisfy_one { |template| template['key'] == 'Default' } - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns 400 bad request like other unknown types' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls") - - expect(response).to have_gitlab_http_status(:bad_request) - end - end - it 'returns issue templates' do get api("/projects/#{private_project.id}/templates/issues", developer) @@ -176,26 +155,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management expect(json_response['name']).to eq('Android') end - it 'returns a specific metrics_dashboard_yml' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default") - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to match_response_schema('public_api/v4/template') - expect(json_response['name']).to eq('Default') - end - - context 'when metrics dashboard feature is unavailable' do - before do - stub_feature_flags(remove_monitor_metrics: true) - end - - it 'returns 400 bad request like other unknown types' do - get api("/projects/#{public_project.id}/templates/metrics_dashboard_ymls/Default") - - expect(response).to have_gitlab_http_status(:bad_request) - end - end - it 'returns a specific license' do get api("/projects/#{public_project.id}/templates/licenses/mit") @@ -256,10 +215,6 @@ RSpec.describe API::ProjectTemplates, feature_category: :source_code_management subject { get api("/projects/#{url_encoded_path}/templates/gitlab_ci_ymls/Android") } end - it_behaves_like 'accepts project paths with dots' do - subject { get api("/projects/#{url_encoded_path}/templates/metrics_dashboard_ymls/Default") } - end - shared_examples 'path traversal attempt' do |template_type| it 'rejects invalid filenames' do get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea") diff --git a/spec/services/submodules/update_service_spec.rb b/spec/services/submodules/update_service_spec.rb index aeaf8ec1c7b..b4282b2a89b 100644 --- a/spec/services/submodules/update_service_spec.rb +++ b/spec/services/submodules/update_service_spec.rb @@ -53,82 +53,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end context 'validations' do - context 'when submodule' do - context 'is empty' do - let(:submodule) { '' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is not present' do - let(:submodule) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is invalid' do - let(:submodule) { 'VERSION' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - - context 'does not exist' do - let(:submodule) { 'non-existent-submodule' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - - context 'has traversal path' do - let(:submodule) { '../six' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid submodule path' } - end - end - end - - context 'commit_sha' do - context 'is empty' do - let(:commit_sha) { '' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is not present' do - let(:commit_sha) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is invalid' do - let(:commit_sha) { '1' } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - - context 'is the same as the current ref' do - let(:commit_sha) { current_sha } - - it_behaves_like 'returns error result' do - let(:error_message) { "The submodule #{submodule} is already at #{commit_sha}" } - end - end - end - context 'branch_name' do context 'is empty' do let(:branch_name) { '' } @@ -138,14 +62,6 @@ RSpec.describe Submodules::UpdateService, feature_category: :source_code_managem end end - context 'is not present' do - let(:branch_name) { nil } - - it_behaves_like 'returns error result' do - let(:error_message) { 'Invalid parameters' } - end - end - context 'does not exist' do let(:branch_name) { 'non/existent-branch' } -- cgit v1.2.3