Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-03-03 12:14:02 +00:00
parent 642ed51ed8
commit aaa65d3249
111 changed files with 2144 additions and 480 deletions

View File

@ -18,10 +18,8 @@ Database/MultipleDatabases:
- lib/gitlab/database/migrations/observers/query_log.rb
- lib/gitlab/database/partitioning_migration_helpers/backfill_partitioned_table.rb
- lib/gitlab/database.rb
- lib/gitlab/gitlab_import/importer.rb
- lib/gitlab/health_checks/db_check.rb
- lib/gitlab/import_export/group/relation_tree_restorer.rb
- lib/gitlab/legacy_github_import/importer.rb
- lib/gitlab/seeder.rb
- spec/db/schema_spec.rb
- spec/initializers/database_config_spec.rb

View File

@ -0,0 +1,4 @@
---
GraphQL/ArgumentUniqueness:
Exclude:
- app/graphql/resolvers/merge_requests_resolver.rb

View File

@ -0,0 +1,5 @@
---
GraphQL/UnusedArgument:
Exclude:
- app/graphql/mutations/jira_import/start.rb
- app/graphql/resolvers/packages_base_resolver.rb

View File

@ -0,0 +1,203 @@
---
RSpec/InstanceVariable:
Exclude:
- ee/spec/controllers/admin/application_settings_controller_spec.rb
- ee/spec/controllers/admin/geo/settings_controller_spec.rb
- ee/spec/controllers/ee/sessions_controller_spec.rb
- ee/spec/controllers/groups/groups_controller_spec.rb
- ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb
- ee/spec/controllers/passwords_controller_spec.rb
- ee/spec/features/markdown/markdown_spec.rb
- ee/spec/frontend/fixtures/dast_profiles.rb
- ee/spec/frontend/fixtures/epic.rb
- ee/spec/graphql/types/vulnerability_request_response_header_type_spec.rb
- ee/spec/graphql/types/vulnerability_request_type_spec.rb
- ee/spec/graphql/types/vulnerability_response_type_spec.rb
- ee/spec/helpers/ee/issuables_helper_spec.rb
- ee/spec/helpers/ee/namespace_storage_limit_alert_helper_spec.rb
- ee/spec/helpers/ee/wiki_helper_spec.rb
- ee/spec/helpers/notes_helper_spec.rb
- ee/spec/helpers/search_helper_spec.rb
- ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
- ee/spec/lib/gitlab/elastic/search_results_spec.rb
- ee/spec/lib/gitlab/reference_extractor_spec.rb
- ee/spec/services/ee/merge_requests/update_service_spec.rb
- ee/spec/services/ee/notification_service_spec.rb
- ee/spec/services/ee/users/create_service_spec.rb
- ee/spec/services/ee/users/destroy_service_spec.rb
- ee/spec/services/geo/metrics_update_service_spec.rb
- ee/spec/services/groups/create_service_spec.rb
- ee/spec/services/groups/participants_service_spec.rb
- ee/spec/services/projects/create_from_template_service_spec.rb
- ee/spec/services/projects/create_service_spec.rb
- ee/spec/support/shared_examples/views/subscription_shared_examples.rb
- ee/spec/tasks/geo_rake_spec.rb
- ee/spec/views/projects/security/corpus_management/show.html.haml_spec.rb
- ee/spec/views/projects/security/dast_profiles/show.html.haml_spec.rb
- ee/spec/views/projects/security/dast_scanner_profiles/new.html.haml_spec.rb
- ee/spec/views/projects/security/dast_site_profiles/new.html.haml_spec.rb
- qa/qa/specs/features/api/1_manage/import_large_github_repo_spec.rb
- qa/qa/specs/features/api/1_manage/project_access_token_spec.rb
- qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/login/2fa_recovery_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/project/dashboard_images_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/project/invite_group_to_project_spec.rb
- qa/qa/specs/features/browser_ui/1_manage/project/protected_tags_spec.rb
- qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
- qa/qa/specs/features/browser_ui/3_create/repository/push_over_ssh_spec.rb
- qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb
- qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
- qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb
- qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb
- qa/qa/specs/features/ee/api/1_manage/user/minimal_access_user_spec.rb
- qa/qa/specs/features/ee/browser_ui/12_geo/attachment_replication_spec.rb
- qa/qa/specs/features/ee/browser_ui/12_geo/geo_replication_ci_job_log_artifacts_spec.rb
- qa/qa/specs/features/ee/browser_ui/12_geo/rename_replication_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/create_merge_request_with_secure_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/license_compliance_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/merge_request_license_widget_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/project_security_dashboard_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/security_reports_spec.rb
- qa/qa/specs/features/ee/browser_ui/13_secure/vulnerability_management_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/group/group_file_template_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/group/group_ldap_sync_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/group/group_saml_non_enforced_sso_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/group/restrict_by_ip_address_spec.rb
- qa/qa/specs/features/ee/browser_ui/1_manage/project/project_templates_spec.rb
- qa/qa/specs/features/ee/browser_ui/2_plan/integrations/jira_issues_list_spec.rb
- qa/qa/specs/features/ee/browser_ui/2_plan/issue_boards/project_issue_boards_spec.rb
- qa/qa/specs/features/ee/browser_ui/2_plan/multiple_assignees_for_issues/more_than_four_assignees_spec.rb
- qa/qa/specs/features/ee/browser_ui/3_create/repository/code_owners_spec.rb
- qa/qa/specs/features/ee/browser_ui/3_create/repository/push_rules_spec.rb
- qa/qa/specs/features/ee/browser_ui/4_verify/cancelling_merge_request_in_merge_train_spec.rb
- qa/spec/support/repeater_spec.rb
- spec/commands/metrics_server/metrics_server_spec.rb
- spec/controllers/admin/clusters_controller_spec.rb
- spec/controllers/admin/topics/avatars_controller_spec.rb
- spec/controllers/concerns/renders_commits_spec.rb
- spec/controllers/confirmations_controller_spec.rb
- spec/controllers/groups/avatars_controller_spec.rb
- spec/controllers/groups/clusters_controller_spec.rb
- spec/controllers/import/bitbucket_controller_spec.rb
- spec/controllers/import/bitbucket_server_controller_spec.rb
- spec/controllers/metrics_controller_spec.rb
- spec/controllers/omniauth_callbacks_controller_spec.rb
- spec/controllers/passwords_controller_spec.rb
- spec/controllers/profiles/avatars_controller_spec.rb
- spec/controllers/projects/clusters_controller_spec.rb
- spec/controllers/sessions_controller_spec.rb
- spec/features/admin/admin_runners_spec.rb
- spec/features/calendar_spec.rb
- spec/features/issues/user_filters_issues_spec.rb
- spec/features/markdown/copy_as_gfm_spec.rb
- spec/features/markdown/gitlab_flavored_markdown_spec.rb
- spec/features/markdown/keyboard_shortcuts_spec.rb
- spec/features/markdown/markdown_spec.rb
- spec/features/merge_request/batch_comments_spec.rb
- spec/features/merge_request/user_sees_pipelines_spec.rb
- spec/features/merge_requests/user_lists_merge_requests_spec.rb
- spec/features/projects/diffs/diff_show_spec.rb
- spec/features/triggers_spec.rb
- spec/features/u2f_spec.rb
- spec/finders/admin/plans_finder_spec.rb
- spec/finders/groups_finder_spec.rb
- spec/finders/issues_finder_spec.rb
- spec/frontend/fixtures/listbox.rb
- spec/frontend/fixtures/raw.rb
- spec/frontend/fixtures/sessions.rb
- spec/frontend/fixtures/tabs.rb
- spec/frontend/fixtures/timezones.rb
- spec/frontend/fixtures/u2f.rb
- spec/frontend/fixtures/webauthn.rb
- spec/helpers/application_helper_spec.rb
- spec/helpers/award_emoji_helper_spec.rb
- spec/helpers/issuables_description_templates_helper_spec.rb
- spec/helpers/issuables_helper_spec.rb
- spec/helpers/notes_helper_spec.rb
- spec/helpers/projects_helper_spec.rb
- spec/helpers/search_helper_spec.rb
- spec/helpers/tree_helper_spec.rb
- spec/helpers/wiki_helper_spec.rb
- spec/lib/api/helpers/authentication_spec.rb
- spec/lib/banzai/filter/asset_proxy_filter_spec.rb
- spec/lib/extracts_path_spec.rb
- spec/lib/extracts_ref_spec.rb
- spec/lib/gitlab/auth/auth_finders_spec.rb
- spec/lib/gitlab/auth/ldap/person_spec.rb
- spec/lib/gitlab/background_migration/recalculate_vulnerabilities_occurrences_uuid_spec.rb
- spec/lib/gitlab/bitbucket_import/importer_spec.rb
- spec/lib/gitlab/chat_name_token_spec.rb
- spec/lib/gitlab/ci/lint_spec.rb
- spec/lib/gitlab/ci/status/composite_spec.rb
- spec/lib/gitlab/contributions_calendar_spec.rb
- spec/lib/gitlab/diff/parser_spec.rb
- spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb
- spec/lib/gitlab/git/commit_spec.rb
- spec/lib/gitlab/git/diff_collection_spec.rb
- spec/lib/gitlab/git/diff_spec.rb
- spec/lib/gitlab/git/repository_spec.rb
- spec/lib/gitlab/http_spec.rb
- spec/lib/gitlab/import_export/group/legacy_tree_restorer_spec.rb
- spec/lib/gitlab/import_export/group/tree_restorer_spec.rb
- spec/lib/gitlab/import_export/project/tree_restorer_spec.rb
- spec/lib/gitlab/patch/prependable_spec.rb
- spec/lib/gitlab/popen_spec.rb
- spec/lib/gitlab/project_transfer_spec.rb
- spec/lib/gitlab/reference_extractor_spec.rb
- spec/lib/gitlab/tcp_checker_spec.rb
- spec/lib/gitlab/user_access_spec.rb
- spec/lib/gitlab/version_info_spec.rb
- spec/lib/gitlab/x509/certificate_spec.rb
- spec/mailers/emails/issues_spec.rb
- spec/migrations/20220106163326_add_has_issues_on_vulnerability_reads_trigger_spec.rb
- spec/migrations/rename_services_to_integrations_spec.rb
- spec/migrations/replace_external_wiki_triggers_spec.rb
- spec/models/group_spec.rb
- spec/models/integrations/assembla_spec.rb
- spec/models/integrations/campfire_spec.rb
- spec/models/integrations/irker_spec.rb
- spec/models/member_spec.rb
- spec/models/members/project_member_spec.rb
- spec/models/namespace_spec.rb
- spec/models/note_spec.rb
- spec/models/postgresql/replication_slot_spec.rb
- spec/models/project_spec.rb
- spec/models/user_spec.rb
- spec/models/users/in_product_marketing_email_spec.rb
- spec/rack_servers/puma_spec.rb
- spec/requests/api/admin/plan_limits_spec.rb
- spec/requests/api/merge_requests_spec.rb
- spec/requests/api/users_spec.rb
- spec/requests/git_http_spec.rb
- spec/requests/openid_connect_spec.rb
- spec/requests/projects/issues/discussions_spec.rb
- spec/rubocop/cop/migration/update_column_in_batches_spec.rb
- spec/serializers/pipeline_serializer_spec.rb
- spec/services/ci/create_pipeline_service/logger_spec.rb
- spec/services/ci/process_sync_events_service_spec.rb
- spec/services/labels/update_service_spec.rb
- spec/services/members/destroy_service_spec.rb
- spec/services/merge_requests/close_service_spec.rb
- spec/services/merge_requests/refresh_service_spec.rb
- spec/services/merge_requests/reopen_service_spec.rb
- spec/services/merge_requests/update_service_spec.rb
- spec/services/milestones/create_service_spec.rb
- spec/services/notes/post_process_service_spec.rb
- spec/services/notes/update_service_spec.rb
- spec/services/notification_service_spec.rb
- spec/services/pages/zip_directory_service_spec.rb
- spec/services/projects/create_from_template_service_spec.rb
- spec/services/projects/download_service_spec.rb
- spec/services/projects/fork_service_spec.rb
- spec/services/upload_service_spec.rb
- spec/support/shared_contexts/controllers/ldap_omniauth_callbacks_controller_shared_context.rb
- spec/support/shared_contexts/email_shared_context.rb
- spec/support/shared_examples/features/wiki/user_views_wiki_empty_shared_examples.rb
- spec/support/shared_examples/path_extraction_shared_examples.rb
- spec/support/shared_examples/requests/api/notes_shared_examples.rb
- spec/support_specs/helpers/stub_feature_flags_spec.rb
- spec/views/search/_results.html.haml_spec.rb
- spec/workers/emails_on_push_worker_spec.rb

File diff suppressed because it is too large Load Diff

View File

@ -374,7 +374,7 @@ group :development, :test do
gem 'spring', '~> 2.1.0'
gem 'spring-commands-rspec', '~> 1.0.4'
gem 'gitlab-styles', '~> 6.6.0', require: false
gem 'gitlab-styles', '~> 7.0.0', require: false
gem 'haml_lint', '~> 0.36.0', require: false
gem 'bundler-audit', '~> 0.7.0.1', require: false

View File

@ -501,7 +501,7 @@ GEM
openid_connect (~> 1.2)
gitlab-sidekiq-fetcher (0.8.0)
sidekiq (~> 6.1)
gitlab-styles (6.6.0)
gitlab-styles (7.0.0)
rubocop (~> 0.91, >= 0.91.1)
rubocop-gitlab-security (~> 0.1.1)
rubocop-graphql (~> 0.10)
@ -1115,7 +1115,7 @@ GEM
parser (>= 2.7.1.5)
rubocop-gitlab-security (0.1.1)
rubocop (>= 0.51)
rubocop-graphql (0.10.3)
rubocop-graphql (0.13.0)
rubocop (>= 0.87, < 2)
rubocop-performance (1.9.2)
rubocop (>= 0.90.0, < 2.0)
@ -1489,7 +1489,7 @@ DEPENDENCIES
gitlab-net-dns (~> 0.9.1)
gitlab-omniauth-openid-connect (~> 0.9.0)
gitlab-sidekiq-fetcher (= 0.8.0)
gitlab-styles (~> 6.6.0)
gitlab-styles (~> 7.0.0)
gitlab_chronic_duration (~> 0.10.6.2)
gitlab_omniauth-ldap (~> 2.1.1)
gon (~> 6.4.0)

View File

@ -78,8 +78,9 @@ module Spammable
end
def recaptcha_error!
self.errors.add(:base, "Your #{spammable_entity_type} has been recognized as spam. "\
"Please, change the content or solve the reCAPTCHA to proceed.")
self.errors.add(:base, _("Your %{spammable_entity_type} has been recognized as spam. "\
"Please, change the content or solve the reCAPTCHA to proceed.") \
% { spammable_entity_type: spammable_entity_type })
end
def unrecoverable_spam_error!

View File

@ -14,4 +14,3 @@
tiers: [Premium, Ultimate]
issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337384
documentation_url: https://docs.gitlab.com/ee/integration/kerberos.html#upgrading-from-password-based-to-ticket-based-kerberos-sign-ins

View File

@ -15,4 +15,3 @@
tiers: [Premium, Ultimate]
issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/350275
documentation_url: https://docs.gitlab.com/ee/integration/elasticsearch.html#version-requirements

View File

@ -13,4 +13,3 @@
documentation_url: https://docs.gitlab.com/ee/operations/#aggregate-and-store-logs-deprecated # (optional) This is a link to the current documentation page
image_url: # (optional) This is a link to a thumbnail image depicting the feature
video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg

View File

@ -14,4 +14,3 @@
documentation_url: https://docs.gitlab.com/ee/operations/metrics/dashboards/ # (optional) This is a link to the current documentation page
image_url: # (optional) This is a link to a thumbnail image depicting the feature
video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg

View File

@ -7,5 +7,3 @@
GitLab supports a [queue selector](https://docs.gitlab.com/ee/administration/operations/extra_sidekiq_processes.html#queue-selector) to run only a subset of background jobs for a given process. When it was introduced, this option had an 'experimental' prefix (`experimental_queue_selector` in Omnibus, `experimentalQueueSelector` in Helm charts).
As announced in the [13.6 release post](https://about.gitlab.com/releases/2020/11/22/gitlab-13-6-released/#sidekiq-cluster-queue-selector-configuration-option-has-been-renamed), the 'experimental' prefix is no longer supported. Instead, `queue_selector` for Omnibus and `queueSelector` in Helm charts should be used.

View File

@ -9,4 +9,3 @@
If you are using `CI_PROJECT_CONFIG_PATH` in your pipeline configurations,
please update them to use `CI_CONFIG_PATH` instead.

View File

@ -7,5 +7,3 @@
PostgreSQL 12 will be the minimum required version in GitLab 14.0. It offers [significant improvements](https://www.postgresql.org/about/news/postgresql-12-released-1976/) to indexing, partitioning, and general performance benefits.
Starting in GitLab 13.7, all new installations default to version 12. From GitLab 13.8, single-node instances are automatically upgraded as well. If you aren't ready to upgrade, you can [opt out of automatic upgrades](https://docs.gitlab.com/omnibus/settings/database.html#opt-out-of-automatic-postgresql-upgrades).

View File

@ -7,6 +7,3 @@
Ubuntu 16.04 [reached end-of-life in April 2021](https://ubuntu.com/about/release-cycle), and no longer receives maintenance updates. We strongly recommend users to upgrade to a newer release, such as 20.04.
GitLab 13.12 will be the last release with Ubuntu 16.04 support.

View File

@ -5,4 +5,3 @@
breaking_change: true
body: |
In GitLab Runner 13.0, [issue #5069](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/5069), we introduced new timing options for the GitLab Docker Machine executor. In GitLab Runner 14.0, we have removed the old configuration option, [off peak time mode](https://docs.gitlab.com/runner/configuration/autoscale.html#off-peak-time-mode-configuration-deprecated).

View File

@ -5,5 +5,3 @@
breaking_change: true
body: |
GitLab Runner was updated in GitLab 13.4 to internally stop passing the `trace` parameter to the `/api/jobs/:id` endpoint. GitLab 14.0 deprecates the `trace` parameter entirely for all other requests of this endpoint. Make sure your [GitLab Runner version matches your GitLab version](https://docs.gitlab.com/runner/#gitlab-runner-versions) to ensure consistent behavior.

View File

@ -0,0 +1,27 @@
# frozen_string_literal: true
class RerunConvertStringifiedRawMetadataHashToJson < Gitlab::Database::Migration[1.0]
MIGRATION_CLASS = Gitlab::BackgroundMigration::FixVulnerabilityOccurrencesWithHashesAsRawMetadata
MODEL_CLASS = MIGRATION_CLASS::Finding
DELAY_INTERVAL = 2.minutes
BATCH_SIZE = 500
disable_ddl_transaction!
def up
queue_background_migration_jobs_by_range_at_intervals(
MODEL_CLASS.by_api_report_types,
MIGRATION_CLASS.name.demodulize,
DELAY_INTERVAL,
batch_size: BATCH_SIZE,
track_jobs: true
)
end
def down
# no-op
# up fixes invalid data by updating columns in-place.
# It is a backwards-compatible change, and reversing it in a downgrade would not be desirable.
end
end

View File

@ -0,0 +1,27 @@
# frozen_string_literal: true
class ScheduleNullifyOrphanRunnerIdOnCiBuilds < Gitlab::Database::Migration[1.0]
MIGRATION = 'NullifyOrphanRunnerIdOnCiBuilds'
INTERVAL = 2.minutes
BATCH_SIZE = 100_000
MAX_BATCH_SIZE = 25_000 # 100k * 25k = 2.5B ci_builds
SUB_BATCH_SIZE = 1_000
def up
queue_batched_background_migration(
MIGRATION,
:ci_builds,
:id,
job_interval: INTERVAL,
batch_size: BATCH_SIZE,
max_batch_size: MAX_BATCH_SIZE,
sub_batch_size: SUB_BATCH_SIZE
)
end
def down
Gitlab::Database::BackgroundMigration::BatchedMigration
.for_configuration(MIGRATION, :ci_builds, :id, [])
.delete_all
end
end

View File

@ -0,0 +1 @@
aa92afc5f74f051132aeb73889d7360bbd6258b27c0aedb4fea6a44ccce597b3

View File

@ -0,0 +1 @@
57dc23bb2a9faddefe20c1e30a8879ebb1f6f32f17e3cc381acc1d06ad3b598a

View File

@ -958,6 +958,32 @@ Parameters:
}
```
## Single SSH key for given user
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81790) in GitLab 14.9.
Get a single key for a given user.
```plaintext
GET /users/:id/keys/:key_id
```
Parameters:
| Attribute | Type | Required | Description |
|-----------|---------|----------|----------------------|
| `id` | integer | yes | ID of specified user |
| `key_id` | integer | yes | SSH key ID |
```json
{
"id": 1,
"title": "Public key",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=",
"created_at": "2014-08-01T14:47:39.080Z"
}
```
## Add SSH key
Creates a new key owned by the currently authenticated user.

View File

@ -223,3 +223,25 @@ On GitLab SaaS an email notification is sent to the namespace owners when:
- The available CI/CD minutes are below 30% of the quota.
- The available CI/CD minutes are below 5% of the quota.
- All CI/CD minutes have been used.
## Reduce consumption of CI/CD minutes
If your project consumes too many CI/CD minutes, there are some strategies you can
use to reduce your CI/CD minutes usage:
- If you are using project mirrors, ensure that [pipelines for mirror updates](../../user/project/repository/mirror/pull.md#trigger-pipelines-for-mirror-updates)
is disabled.
- Reduce the frequency of [pipeline schedules](schedules.md#pipeline-schedules).
- [Skip pipelines](index.md#skip-a-pipeline) when not needed.
- Use [interruptible](../yaml/index.md#interruptible) jobs which can be auto-canceled
if a new pipeline starts.
- If a job doesn't have to run in every pipeline, use [`rules`](../jobs/job_control.md)
to make it only run when it's needed.
- [Use private runners](../runners/runners_scope.md#group-runners) for some jobs.
- If you are working from a fork and you submit a merge request to the parent project,
you can ask a maintainer to run a pipeline [in the parent project](merge_request_pipelines.md#run-pipelines-in-the-parent-project).
If you manage an open source project, these improvements can also reduce CI/CD minutes
consumption for contributor fork projects, enabling more contributions.
See our [pipeline efficiency guide](pipeline_efficiency.md) for more details.

View File

@ -275,11 +275,11 @@ You can verify if the MR was deployed to GitLab.com by executing
`/chatops run auto_deploy status <merge_sha>`. To verify existence of
the index, you can:
- Use a meta-command in #database-lab, such as: `\d <index_name>`
- Ensure that the index is not [`invalid`](https://www.postgresql.org/docs/12/sql-createindex.html#:~:text=The%20psql%20%5Cd%20command%20will%20report%20such%20an%20index%20as%20INVALID)
- Ask someone in #database to check if the index exists
- Use a meta-command in #database-lab, such as: `\d <index_name>`.
- Ensure that the index is not [`invalid`](https://www.postgresql.org/docs/12/sql-createindex.html#:~:text=The%20psql%20%5Cd%20command%20will%20report%20such%20an%20index%20as%20INVALID).
- Ask someone in #database to check if the index exists.
- With proper access, you can also verify directly on production or in a
production clone
production clone.
### Add a migration to create the index synchronously

View File

@ -26,13 +26,12 @@ To implement a new metric in Service Ping, follow these steps:
1. [Verify your metric](#verify-your-metric)
1. [Set up and test Service Ping locally](#set-up-and-test-service-ping-locally)
NOTE:
When you add or change a Service Metric, you must migrate metrics to [instrumentation classes](metrics_instrumentation.md).
For information about the progress on migrating Service ping metrics, see this [epic](https://gitlab.com/groups/gitlab-org/-/epics/5547).
## Instrumentation classes
Implementing metrics direct in `usage_data.rb` is deprecated, we recommend you use [instrumentation classes](metrics_instrumentation.md).
NOTE:
Implementing metrics directly in `usage_data.rb` is deprecated.
When you add or change a Service Ping Metric, you must migrate metrics to [instrumentation classes](metrics_instrumentation.md).
For information about the progress on migrating Service Ping metrics, see this [epic](https://gitlab.com/groups/gitlab-org/-/epics/5547).
For example, we have the following instrumentation class:
`lib/gitlab/usage/metrics/instrumentations/count_boards_metric.rb`.

View File

@ -56,7 +56,7 @@ Otherwise, to upload your license:
1. Sign in to GitLab as an administrator.
1. On the top bar, select **Menu > Admin**.
1. On the left sidebar, select **Settings**.
1. On the left sidebar, select **Settings > General**.
1. In the **License file** area, select **Upload a license**.
1. Upload a license:
- For a file, either:

View File

@ -383,6 +383,23 @@ module API
present paginate(keys), with: Entities::SSHKey
end
desc 'Get a SSH key of a specified user.' do
success Entities::SSHKey
end
params do
requires :id, type: Integer, desc: 'The ID of the user'
requires :key_id, type: Integer, desc: 'The ID of the SSH key'
end
get ':id/keys/:key_id', requirements: API::USER_REQUIREMENTS, feature_category: :authentication_and_authorization do
user = find_user(params[:id])
not_found!('User') unless user && can?(current_user, :read_user, user)
key = user.keys.find_by(id: params[:key_id]) # rubocop: disable CodeReuse/ActiveRecord
not_found!('Key') unless key
present key, with: Entities::SSHKey
end
desc 'Delete an existing SSH key from a specified user. Available only for admins.' do
success Entities::SSHKey
end

View File

@ -59,7 +59,7 @@ module Gitlab
private
def mark_job_as_succeeded(*arguments)
Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(
::Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(
'FixVulnerabilityOccurrencesWithHashesAsRawMetadata',
arguments
)

View File

@ -0,0 +1,40 @@
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# A job to nullify orphan runner_id on ci_builds table
class NullifyOrphanRunnerIdOnCiBuilds
include Gitlab::Database::DynamicModelHelpers
def perform(start_id, end_id, batch_table, batch_column, sub_batch_size, pause_ms)
pause_ms = 0 if pause_ms < 0
batch_relation = relation_scoped_to_range(batch_table, batch_column, start_id, end_id)
batch_relation.each_batch(column: batch_column, of: sub_batch_size, order_hint: :type) do |sub_batch|
batch_metrics.time_operation(:update_all) do
sub_batch.update_all(runner_id: nil)
end
sleep(pause_ms * 0.001)
end
end
def batch_metrics
@batch_metrics ||= Gitlab::Database::BackgroundMigration::BatchMetrics.new
end
private
def connection
ActiveRecord::Base.connection
end
def relation_scoped_to_range(source_table, source_key_column, start_id, stop_id)
define_batchable_model(source_table, connection: connection)
.joins('LEFT OUTER JOIN ci_runners ON ci_runners.id = ci_builds.runner_id')
.where('ci_builds.runner_id IS NOT NULL AND ci_runners.id IS NULL')
.where(source_key_column => start_id..stop_id)
end
end
end
end

View File

@ -42389,6 +42389,9 @@ msgstr ""
msgid "Your %{plan} subscription expires on %{expiry_date}"
msgstr ""
msgid "Your %{spammable_entity_type} has been recognized as spam. Please, change the content or solve the reCAPTCHA to proceed."
msgstr ""
msgid "Your %{strong}%{plan_name}%{strong_close} subscription expires on %{strong}%{expires_on}%{strong_close}. After that date, you cannot create issues or merge requests, or use many other features."
msgstr ""

View File

@ -17,6 +17,10 @@ module RuboCop
https://docs.gitlab.com/ee/development/database/transaction_guidelines.html
EOF
ALLOWED_METHODS = %i[
no_touching
].freeze
def_node_matcher :active_record_base_method_is_used?, <<~PATTERN
(send (const (const nil? :ActiveRecord) :Base) $_)
PATTERN
@ -24,8 +28,17 @@ module RuboCop
def on_send(node)
return unless active_record_base_method_is_used?(node)
active_record_base_method = node.children[1]
return if method_is_allowed?(active_record_base_method)
add_offense(node, location: :expression, message: AR_BASE_MESSAGE)
end
private
def method_is_allowed?(method_name)
ALLOWED_METHODS.include?(method_name.to_sym)
end
end
end
end

View File

@ -152,7 +152,7 @@ RSpec.describe ConfirmationsController do
perform_request
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
end
it 'successfully sends password reset when reCAPTCHA is solved' do

View File

@ -121,7 +121,7 @@ RSpec.describe PasswordsController do
perform_request
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
end
it 'successfully sends password reset when reCAPTCHA is solved' do

View File

@ -235,7 +235,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params)
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
@ -259,7 +259,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params, sesion_params: { failed_login_attempts: 6 })
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
@ -279,7 +279,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params)
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end

View File

@ -324,7 +324,7 @@ RSpec.describe 'Signup' do
fill_in_signup_form
expect { click_button 'Register' }.not_to change { User.count }
expect(page).to have_content('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(page).to have_content(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
end
end

View File

@ -0,0 +1,49 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::NullifyOrphanRunnerIdOnCiBuilds, :migration, schema: 20220223112304 do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:ci_runners) { table(:ci_runners) }
let(:ci_pipelines) { table(:ci_pipelines) }
let(:ci_builds) { table(:ci_builds) }
subject { described_class.new }
let(:helpers) do
ActiveRecord::Migration.new.extend(Gitlab::Database::MigrationHelpers)
end
before do
helpers.remove_foreign_key_if_exists(:ci_builds, column: :runner_id)
end
after do
helpers.add_concurrent_foreign_key(:ci_builds, :ci_runners, column: :runner_id, on_delete: :nullify, validate: false)
end
describe '#perform' do
let(:namespace) { namespaces.create!(name: 'test', path: 'test', type: 'Group') }
let(:project) { projects.create!(namespace_id: namespace.id, name: 'test') }
let(:pipeline) { ci_pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a', status: 'success') }
it 'nullifies runner_id for orphan ci_builds in range' do
ci_runners.create!(id: 2, runner_type: 'project_type')
ci_builds.create!(id: 5, type: 'Ci::Build', commit_id: pipeline.id, runner_id: 2)
ci_builds.create!(id: 7, type: 'Ci::Build', commit_id: pipeline.id, runner_id: 4)
ci_builds.create!(id: 8, type: 'Ci::Build', commit_id: pipeline.id, runner_id: 5)
ci_builds.create!(id: 9, type: 'Ci::Build', commit_id: pipeline.id, runner_id: 6)
subject.perform(4, 8, :ci_builds, :id, 10, 0)
expect(ci_builds.all).to contain_exactly(
an_object_having_attributes(id: 5, runner_id: 2),
an_object_having_attributes(id: 7, runner_id: nil),
an_object_having_attributes(id: 8, runner_id: nil),
an_object_having_attributes(id: 9, runner_id: 6)
)
end
end
end

View File

@ -55,7 +55,7 @@ RSpec.describe Spammable do
subject { invalidate_if_spam(needs_recaptcha: true) }
it 'has an error related to spam on the model' do
expect(subject.errors.messages[:base]).to match_array /solve the reCAPTCHA/
expect(subject.errors.messages[:base]).to match_array /content or solve the/
end
end
@ -63,7 +63,7 @@ RSpec.describe Spammable do
subject { invalidate_if_spam(is_spam: true, needs_recaptcha: true) }
it 'has an error related to spam on the model' do
expect(subject.errors.messages[:base]).to match_array /solve the reCAPTCHA/
expect(subject.errors.messages[:base]).to match_array /content or solve the/
end
end

View File

@ -1735,6 +1735,33 @@ RSpec.describe API::Users do
end
end
describe 'GET /user/:id/keys/:key_id' do
it 'gets existing key', :aggregate_failures do
user.keys << key
get api("/users/#{user.id}/keys/#{key.id}")
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(key.title)
end
it 'returns 404 error if user not found', :aggregate_failures do
user.keys << key
get api("/users/0/keys/#{key.id}")
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if key not found', :aggregate_failures do
get api("/users/#{user.id}/keys/#{non_existing_record_id}")
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Key Not Found')
end
end
describe 'DELETE /user/:id/keys/:key_id' do
context 'when unauthenticated' do
it 'returns authentication error' do

View File

@ -12,4 +12,14 @@ RSpec.describe RuboCop::Cop::Database::MultipleDatabases do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use methods from ActiveRecord::Base, [...]
SOURCE
end
described_class::ALLOWED_METHODS.each do |method_name|
it "does not flag use of ActiveRecord::Base.#{method_name}" do
expect_no_offenses(<<~SOURCE)
ActiveRecord::Base.#{method_name} do
Project.save
end
SOURCE
end
end
end