Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab/issue_templates/Productivity Improvement.md5
-rw-r--r--.rubocop.yml5
-rw-r--r--app/assets/javascripts/alert_management/components/alert_details.vue41
-rw-r--r--app/assets/javascripts/ide/components/ide_tree.vue2
-rw-r--r--app/assets/stylesheets/pages/alert_management/details.scss42
-rw-r--r--app/assets/stylesheets/pages/alert_management/list.scss (renamed from app/assets/stylesheets/pages/alerts_list.scss)35
-rw-r--r--app/assets/stylesheets/pages/alert_management/severity-icons.scss26
-rw-r--r--app/graphql/mutations/metrics/dashboard/annotations/create.rb106
-rw-r--r--app/graphql/types/mutation_type.rb1
-rw-r--r--app/models/project_authorization.rb3
-rw-r--r--app/models/project_services/chat_message/merge_message.rb4
-rw-r--r--app/models/snippet.rb7
-rw-r--r--app/services/alert_management/create_alert_issue_service.rb2
-rw-r--r--app/workers/concerns/application_worker.rb17
-rw-r--r--changelogs/unreleased/211461-create-annotations-graphql-endpoint.yml5
-rw-r--r--changelogs/unreleased/214243.yml5
-rw-r--r--changelogs/unreleased/app-models-3.yml5
-rw-r--r--changelogs/unreleased/fj-add-presence-validation-rest-snippet-endpoints.yml5
-rw-r--r--changelogs/unreleased/leaky-constant-fix-1.yml5
-rw-r--r--changelogs/unreleased/leaky-constant-fix-10.yml5
-rw-r--r--changelogs/unreleased/leaky-constant-fix-6.yml5
-rw-r--r--changelogs/unreleased/leaky-constant-fix-8.yml5
-rw-r--r--changelogs/unreleased/merge-requests-spec.yml5
-rw-r--r--changelogs/unreleased/pipelines-spec.yml5
-rw-r--r--changelogs/unreleased/update-deprecated-slot-syntax-in---javascripts-ide-ide_tree-vue.yml (renamed from changelogs/unreleased/update-deprecated-slot-syntax-in---app-assets-javascripts-ide-components-.yml)0
-rw-r--r--changelogs/unreleased/user-api-spec.yml5
-rw-r--r--doc/administration/packages/container_registry.md2
-rw-r--r--doc/administration/raketasks/storage.md281
-rw-r--r--doc/administration/repository_storage_types.md165
-rw-r--r--doc/api/graphql/reference/gitlab_schema.graphql61
-rw-r--r--doc/api/graphql/reference/gitlab_schema.json187
-rw-r--r--doc/api/graphql/reference/index.md10
-rw-r--r--doc/development/import_export.md10
-rw-r--r--doc/development/licensed_feature_availability.md4
-rw-r--r--doc/user/admin_area/settings/index.md2
-rw-r--r--doc/user/packages/container_registry/index.md48
-rw-r--r--lib/api/project_snippets.rb6
-rw-r--r--lib/api/snippets.rb8
-rw-r--r--lib/gitlab/alerting/notification_payload_parser.rb4
-rw-r--r--lib/gitlab/git_access_snippet.rb2
-rw-r--r--lib/gitlab/sidekiq_logging/structured_logger.rb7
-rw-r--r--lib/gitlab/sidekiq_middleware.rb1
-rw-r--r--lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb25
-rw-r--r--locale/gitlab.pot9
-rw-r--r--spec/frontend/alert_management/components/alert_management_detail_spec.js10
-rw-r--r--spec/lib/gitlab/checks/push_file_count_check_spec.rb4
-rw-r--r--spec/lib/gitlab/git_access_snippet_spec.rb10
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb21
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/extra_done_log_metadata_spec.rb35
-rw-r--r--spec/lib/gitlab/sidekiq_middleware_spec.rb2
-rw-r--r--spec/models/snippet_spec.rb16
-rw-r--r--spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb231
-rw-r--r--spec/requests/api/graphql/project/alert_management/alerts_spec.rb9
-rw-r--r--spec/requests/api/merge_requests_spec.rb12
-rw-r--r--spec/requests/api/pipelines_spec.rb30
-rw-r--r--spec/requests/api/project_snippets_spec.rb21
-rw-r--r--spec/requests/api/snippets_spec.rb59
-rw-r--r--spec/requests/api/users_spec.rb6
-rw-r--r--spec/services/alert_management/create_alert_issue_service_spec.rb12
-rw-r--r--spec/services/ci/retry_build_service_spec.rb14
-rw-r--r--spec/services/clusters/applications/check_upgrade_progress_service_spec.rb4
-rw-r--r--spec/services/metrics/dashboard/clone_dashboard_service_spec.rb4
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/support/helpers/test_env.rb2
-rw-r--r--spec/uploaders/records_uploads_spec.rb4
-rw-r--r--spec/workers/concerns/application_worker_spec.rb15
66 files changed, 1280 insertions, 428 deletions
diff --git a/.gitlab/issue_templates/Productivity Improvement.md b/.gitlab/issue_templates/Productivity Improvement.md
index 79e1461392e..974f11f6da3 100644
--- a/.gitlab/issue_templates/Productivity Improvement.md
+++ b/.gitlab/issue_templates/Productivity Improvement.md
@@ -1,7 +1,7 @@
-## What is the productivity problem to solve?
+## What is the GitLab engineering productivity problem to solve?
<!--
-Please describe the productivity problem that needs to be solved backed by charts from
+Please describe the engineering productivity problem that needs to be solved backed by charts from
https://about.gitlab.com/handbook/engineering/quality/engineering-productivity-team/#engineering-productivity-team-metrics.
-->
@@ -37,4 +37,3 @@ after the implementation is merged/deployed/released.
- Otherwise, create a new "Productivity Improvement" issue. You can re-use the description from this issue, but obviously another solution should be chosen this time.
/label ~"Engineering Productivity" ~meta
-/cc @gl-quality/eng-prod
diff --git a/.rubocop.yml b/.rubocop.yml
index 439a22d00d3..10f280020f4 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -393,17 +393,12 @@ RSpec/LeakyConstantDeclaration:
- 'spec/requests/api/statistics_spec.rb'
- 'spec/rubocop/cop/rspec/env_assignment_spec.rb'
- 'spec/serializers/commit_entity_spec.rb'
- - 'spec/services/ci/retry_build_service_spec.rb'
- 'spec/services/clusters/applications/check_installation_progress_service_spec.rb'
- 'spec/services/clusters/applications/check_uninstall_progress_service_spec.rb'
- - 'spec/services/clusters/applications/check_upgrade_progress_service_spec.rb'
- - 'spec/services/clusters/applications/ingress_modsecurity_usage_service_spec.rb'
- 'spec/services/issues/resolve_discussions_spec.rb'
- - 'spec/services/metrics/dashboard/clone_dashboard_service_spec.rb'
- 'spec/support/shared_contexts/spam_constants.rb'
- 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb'
- 'spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb'
- - 'spec/uploaders/records_uploads_spec.rb'
RSpec/EmptyLineAfterHook:
Enabled: false
diff --git a/app/assets/javascripts/alert_management/components/alert_details.vue b/app/assets/javascripts/alert_management/components/alert_details.vue
index 272caa11e03..89db7db77d5 100644
--- a/app/assets/javascripts/alert_management/components/alert_details.vue
+++ b/app/assets/javascripts/alert_management/components/alert_details.vue
@@ -10,6 +10,7 @@ import {
GlTabs,
GlTab,
GlButton,
+ GlTable,
} from '@gitlab/ui';
import createFlash from '~/flash';
import { s__ } from '~/locale';
@@ -30,7 +31,7 @@ export default {
errorMsg: s__(
'AlertManagement|There was an error displaying the alert. Please refresh the page to try again.',
),
- fullAlertDetailsTitle: s__('AlertManagement|Full alert details'),
+ fullAlertDetailsTitle: s__('AlertManagement|Alert details'),
overviewTitle: s__('AlertManagement|Overview'),
reportedAt: s__('AlertManagement|Reported %{when}'),
reportedAtWithTool: s__('AlertManagement|Reported %{when} by %{tool}'),
@@ -46,6 +47,7 @@ export default {
GlTab,
GlTabs,
GlButton,
+ GlTable,
TimeAgoTooltip,
},
mixins: [glFeatureFlagsMixin()],
@@ -149,18 +151,16 @@ export default {
<strong>{{ $options.severityLabels[alert.severity] }}</strong>
</div>
<span class="mx-2">&bull;</span>
- <span>
- <gl-sprintf :message="reportedAtMessage">
- <template #when>
- <time-ago-tooltip :time="alert.createdAt" />
- </template>
- <template #tool>{{ alert.monitoringTool }}</template>
- </gl-sprintf>
- </span>
+ <gl-sprintf :message="reportedAtMessage">
+ <template #when>
+ <time-ago-tooltip :time="alert.createdAt" class="gl-ml-3" />
+ </template>
+ <template #tool>{{ alert.monitoringTool }}</template>
+ </gl-sprintf>
</div>
<gl-button
v-if="glFeatures.createIssueFromAlertEnabled"
- class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline"
+ class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-create-issue-button"
data-testid="createIssueBtn"
:href="newIssuePath"
category="primary"
@@ -215,13 +215,20 @@ export default {
</ul>
</gl-tab>
<gl-tab data-testid="fullDetailsTab" :title="$options.i18n.fullAlertDetailsTitle">
- <ul class="list-unstyled">
- <li v-for="(value, key) in alert" v-if="key !== '__typename'" :key="key">
- <p class="py-1 my-1 gl-font-base">
- <strong>{{ key }}: </strong> {{ value }}
- </p>
- </li>
- </ul>
+ <gl-table
+ class="alert-management-details-table"
+ :items="[{ key: 'Value', ...alert }]"
+ :show-empty="true"
+ :busy="loading"
+ stacked
+ >
+ <template #empty>
+ {{ s__('AlertManagement|No alert data to display.') }}
+ </template>
+ <template #table-busy>
+ <gl-loading-icon size="lg" color="dark" class="mt-3" />
+ </template>
+ </gl-table>
</gl-tab>
</gl-tabs>
</div>
diff --git a/app/assets/javascripts/ide/components/ide_tree.vue b/app/assets/javascripts/ide/components/ide_tree.vue
index d78cddc0953..647f4d4be85 100644
--- a/app/assets/javascripts/ide/components/ide_tree.vue
+++ b/app/assets/javascripts/ide/components/ide_tree.vue
@@ -42,7 +42,7 @@ export default {
<template>
<ide-tree-list viewer-type="editor">
- <template slot="header">
+ <template #header>
{{ __('Edit') }}
<div class="ide-tree-actions ml-auto d-flex">
<new-entry-button
diff --git a/app/assets/stylesheets/pages/alert_management/details.scss b/app/assets/stylesheets/pages/alert_management/details.scss
new file mode 100644
index 00000000000..89219e41644
--- /dev/null
+++ b/app/assets/stylesheets/pages/alert_management/details.scss
@@ -0,0 +1,42 @@
+.alert-management-details {
+ // these styles need to be deleted once GlTable component looks in GitLab same as in @gitlab/ui
+ table {
+ tr {
+ td {
+ @include gl-border-0;
+ @include gl-p-5;
+ border-color: transparent;
+ border-bottom: 1px solid $table-border-color;
+
+ &:first-child {
+ div {
+ font-weight: bold;
+ }
+ }
+
+ &:not(:first-child) {
+ &::before {
+ color: $gray-700;
+ font-weight: normal !important;
+ }
+
+ div {
+ color: $gray-700;
+ }
+ }
+
+ @include media-breakpoint-up(sm) {
+ div {
+ text-align: left !important;
+ }
+ }
+ }
+ }
+ }
+
+ @include media-breakpoint-down(xs) {
+ .alert-details-create-issue-button {
+ width: 100%;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/pages/alerts_list.scss b/app/assets/stylesheets/pages/alert_management/list.scss
index 8eae2b3da1c..3fda66adc87 100644
--- a/app/assets/stylesheets/pages/alerts_list.scss
+++ b/app/assets/stylesheets/pages/alert_management/list.scss
@@ -1,30 +1,4 @@
-.alert-management-list,
-.alert-management-details {
- .icon-critical {
- color: $red-800;
- }
-
- .icon-high {
- color: $red-600;
- }
-
- .icon-medium {
- color: $orange-400;
- }
-
- .icon-low {
- color: $orange-300;
- }
-
- .icon-info {
- color: $blue-400;
- }
-
- .icon-unknown {
- color: $gray-400;
- }
-
-
+.alert-management-list {
// consider adding these stateful variants to @gitlab-ui
// https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1178
.hover-bg-blue-50:hover {
@@ -97,13 +71,6 @@
}
}
- @include media-breakpoint-down(xs) {
- // TODO Remove in favour of a details CSS page
- [data-testid='createIssueBtn'] {
- width: 100%;
- }
- }
-
.gl-tab-nav-item {
color: $gl-gray-600;
diff --git a/app/assets/stylesheets/pages/alert_management/severity-icons.scss b/app/assets/stylesheets/pages/alert_management/severity-icons.scss
new file mode 100644
index 00000000000..b400e80d5c5
--- /dev/null
+++ b/app/assets/stylesheets/pages/alert_management/severity-icons.scss
@@ -0,0 +1,26 @@
+.alert-management-list,
+.alert-management-details {
+ .icon-critical {
+ color: $red-800;
+ }
+
+ .icon-high {
+ color: $red-600;
+ }
+
+ .icon-medium {
+ color: $orange-400;
+ }
+
+ .icon-low {
+ color: $orange-300;
+ }
+
+ .icon-info {
+ color: $blue-400;
+ }
+
+ .icon-unknown {
+ color: $gray-400;
+ }
+}
diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
new file mode 100644
index 00000000000..f99688aeac6
--- /dev/null
+++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb
@@ -0,0 +1,106 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Metrics
+ module Dashboard
+ module Annotations
+ class Create < BaseMutation
+ graphql_name 'CreateAnnotation'
+
+ ANNOTATION_SOURCE_ARGUMENT_ERROR = 'Either a cluster or environment global id is required'
+ INVALID_ANNOTATION_SOURCE_ERROR = 'Invalid cluster or environment id'
+
+ authorize :create_metrics_dashboard_annotation
+
+ field :annotation,
+ Types::Metrics::Dashboards::AnnotationType,
+ null: true,
+ description: 'The created annotation'
+
+ argument :environment_id,
+ GraphQL::ID_TYPE,
+ required: false,
+ description: 'The global id of the environment to add an annotation to'
+
+ argument :cluster_id,
+ GraphQL::ID_TYPE,
+ required: false,
+ description: 'The global id of the cluster to add an annotation to'
+
+ argument :starting_at, Types::TimeType,
+ required: true,
+ description: 'Timestamp indicating starting moment to which the annotation relates'
+
+ argument :ending_at, Types::TimeType,
+ required: false,
+ description: 'Timestamp indicating ending moment to which the annotation relates'
+
+ argument :dashboard_path,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: 'The path to a file defining the dashboard on which the annotation should be added'
+
+ argument :description,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: 'The description of the annotation'
+
+ AnnotationSource = Struct.new(:object, keyword_init: true) do
+ def type_keys
+ { 'Clusters::Cluster' => :cluster, 'Environment' => :environment }
+ end
+
+ def klass
+ object.class.name
+ end
+
+ def type
+ raise Gitlab::Graphql::Errors::ArgumentError, INVALID_ANNOTATION_SOURCE_ERROR unless type_keys[klass]
+
+ type_keys[klass]
+ end
+ end
+
+ def resolve(args)
+ annotation_response = ::Metrics::Dashboard::Annotations::CreateService.new(context[:current_user], annotation_create_params(args)).execute
+
+ annotation = annotation_response[:annotation]
+
+ {
+ annotation: annotation.valid? ? annotation : nil,
+ errors: errors_on_object(annotation)
+ }
+ end
+
+ private
+
+ def ready?(**args)
+ # Raise error if both cluster_id and environment_id are present or neither is present
+ unless args[:cluster_id].present? ^ args[:environment_id].present?
+ raise Gitlab::Graphql::Errors::ArgumentError, ANNOTATION_SOURCE_ARGUMENT_ERROR
+ end
+
+ super(args)
+ end
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id)
+ end
+
+ def annotation_create_params(args)
+ annotation_source = AnnotationSource.new(object: annotation_source(args))
+
+ args[annotation_source.type] = annotation_source.object
+
+ args
+ end
+
+ def annotation_source(args)
+ annotation_source_id = args[:cluster_id] || args[:environment_id]
+ authorized_find!(id: annotation_source_id)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index 309864c83be..aeff84b83b8 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -22,6 +22,7 @@ module Types
mount_mutation Mutations::MergeRequests::SetSubscription
mount_mutation Mutations::MergeRequests::SetWip, calls_gitaly: true
mount_mutation Mutations::MergeRequests::SetAssignees
+ mount_mutation Mutations::Metrics::Dashboard::Annotations::Create
mount_mutation Mutations::Notes::Create::Note, calls_gitaly: true
mount_mutation Mutations::Notes::Create::DiffNote, calls_gitaly: true
mount_mutation Mutations::Notes::Create::ImageDiffNote, calls_gitaly: true
diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb
index e81d9d0f5fe..366852d93bf 100644
--- a/app/models/project_authorization.rb
+++ b/app/models/project_authorization.rb
@@ -2,7 +2,6 @@
class ProjectAuthorization < ApplicationRecord
include FromUnion
- prepend_if_ee('::EE::ProjectAuthorization') # rubocop: disable Cop/InjectEnterpriseEditionModule
belongs_to :user
belongs_to :project
@@ -30,3 +29,5 @@ class ProjectAuthorization < ApplicationRecord
end
end
end
+
+ProjectAuthorization.prepend_if_ee('::EE::ProjectAuthorization')
diff --git a/app/models/project_services/chat_message/merge_message.rb b/app/models/project_services/chat_message/merge_message.rb
index dc62a4c8908..0a2d9120adc 100644
--- a/app/models/project_services/chat_message/merge_message.rb
+++ b/app/models/project_services/chat_message/merge_message.rb
@@ -2,8 +2,6 @@
module ChatMessage
class MergeMessage < BaseMessage
- prepend_if_ee('::EE::ChatMessage::MergeMessage') # rubocop: disable Cop/InjectEnterpriseEditionModule
-
attr_reader :merge_request_iid
attr_reader :source_branch
attr_reader :target_branch
@@ -71,3 +69,5 @@ module ChatMessage
end
end
end
+
+ChatMessage::MergeMessage.prepend_if_ee('::EE::ChatMessage::MergeMessage')
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 37bbf3bbb9a..72ebdf61787 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -18,7 +18,8 @@ class Snippet < ApplicationRecord
include AfterCommitQueue
extend ::Gitlab::Utils::Override
- MAX_FILE_COUNT = 1
+ MAX_FILE_COUNT = 10
+ MAX_SINGLE_FILE_COUNT = 1
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description
@@ -169,6 +170,10 @@ class Snippet < ApplicationRecord
Snippet.find_by(id: id, project: project)
end
+ def self.max_file_limit(user)
+ Feature.enabled?(:snippet_multiple_files, user) ? MAX_FILE_COUNT : MAX_SINGLE_FILE_COUNT
+ end
+
def initialize(attributes = {})
# We can't use default_value_for because the database has a default
# value of 0 for visibility_level. If someone attempts to create a
diff --git a/app/services/alert_management/create_alert_issue_service.rb b/app/services/alert_management/create_alert_issue_service.rb
index 9fb6c21ad45..0197f29145d 100644
--- a/app/services/alert_management/create_alert_issue_service.rb
+++ b/app/services/alert_management/create_alert_issue_service.rb
@@ -30,7 +30,7 @@ module AlertManagement
def allowed?
Feature.enabled?(:alert_management_create_alert_issue, project) &&
- user.can?(:update_alert_management_alert, project)
+ user.can?(:create_issue, project)
end
def create_issue(alert, user, alert_payload)
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb
index c0062780688..7ab9a0c2a02 100644
--- a/app/workers/concerns/application_worker.rb
+++ b/app/workers/concerns/application_worker.rb
@@ -11,6 +11,8 @@ module ApplicationWorker
include WorkerAttributes
include WorkerContext
+ LOGGING_EXTRA_KEY = 'extra'
+
included do
set_queue
@@ -24,6 +26,21 @@ module ApplicationWorker
payload.stringify_keys.merge(context)
end
+
+ def log_extra_metadata_on_done(key, value)
+ @done_log_extra_metadata ||= {}
+ @done_log_extra_metadata[key] = value
+ end
+
+ def logging_extras
+ return {} unless @done_log_extra_metadata
+
+ # Prefix keys with class name to avoid conflicts in Elasticsearch types.
+ # Also prefix with "extra." so that we know to log these new fields.
+ @done_log_extra_metadata.transform_keys do |k|
+ "#{LOGGING_EXTRA_KEY}.#{self.class.name.gsub("::", "_").underscore}.#{k}"
+ end
+ end
end
class_methods do
diff --git a/changelogs/unreleased/211461-create-annotations-graphql-endpoint.yml b/changelogs/unreleased/211461-create-annotations-graphql-endpoint.yml
new file mode 100644
index 00000000000..5a9bfb7a0fc
--- /dev/null
+++ b/changelogs/unreleased/211461-create-annotations-graphql-endpoint.yml
@@ -0,0 +1,5 @@
+---
+title: Create dashboard annotations via Graphql
+merge_request: 31249
+author:
+type: added
diff --git a/changelogs/unreleased/214243.yml b/changelogs/unreleased/214243.yml
new file mode 100644
index 00000000000..5b26cac461a
--- /dev/null
+++ b/changelogs/unreleased/214243.yml
@@ -0,0 +1,5 @@
+---
+title: Format the alert payload into a table view
+merge_request: 32423
+author:
+type: changed
diff --git a/changelogs/unreleased/app-models-3.yml b/changelogs/unreleased/app-models-3.yml
new file mode 100644
index 00000000000..8e06346701b
--- /dev/null
+++ b/changelogs/unreleased/app-models-3.yml
@@ -0,0 +1,5 @@
+---
+title: Move prepend to last line in app models 3
+merge_request: 31829
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/fj-add-presence-validation-rest-snippet-endpoints.yml b/changelogs/unreleased/fj-add-presence-validation-rest-snippet-endpoints.yml
new file mode 100644
index 00000000000..2abea83c135
--- /dev/null
+++ b/changelogs/unreleased/fj-add-presence-validation-rest-snippet-endpoints.yml
@@ -0,0 +1,5 @@
+---
+title: Add presence validation to content and title in snippet rest endpoints
+merge_request: 32522
+author:
+type: changed
diff --git a/changelogs/unreleased/leaky-constant-fix-1.yml b/changelogs/unreleased/leaky-constant-fix-1.yml
new file mode 100644
index 00000000000..f0a9df59e4a
--- /dev/null
+++ b/changelogs/unreleased/leaky-constant-fix-1.yml
@@ -0,0 +1,5 @@
+---
+title: Add class stubs and fix leaky constant cop alert
+merge_request: 31938
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/leaky-constant-fix-10.yml b/changelogs/unreleased/leaky-constant-fix-10.yml
new file mode 100644
index 00000000000..696bb5aeaa4
--- /dev/null
+++ b/changelogs/unreleased/leaky-constant-fix-10.yml
@@ -0,0 +1,5 @@
+---
+title: Fix leaky constant issue in retry build service check
+merge_request: 32038
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/leaky-constant-fix-6.yml b/changelogs/unreleased/leaky-constant-fix-6.yml
new file mode 100644
index 00000000000..d4b83631f0b
--- /dev/null
+++ b/changelogs/unreleased/leaky-constant-fix-6.yml
@@ -0,0 +1,5 @@
+---
+title: Fix leaky constant cop issue in clone dashboard service spec
+merge_request: 31962
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/leaky-constant-fix-8.yml b/changelogs/unreleased/leaky-constant-fix-8.yml
new file mode 100644
index 00000000000..8b55a9a1e41
--- /dev/null
+++ b/changelogs/unreleased/leaky-constant-fix-8.yml
@@ -0,0 +1,5 @@
+---
+title: Fix leaky constant issue in upgrade progress service check
+merge_request: 31969
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/merge-requests-spec.yml b/changelogs/unreleased/merge-requests-spec.yml
new file mode 100644
index 00000000000..7f2588cd910
--- /dev/null
+++ b/changelogs/unreleased/merge-requests-spec.yml
@@ -0,0 +1,5 @@
+---
+title: Replace let! with let_it_be in merge request spec
+merge_request: 31909
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/pipelines-spec.yml b/changelogs/unreleased/pipelines-spec.yml
new file mode 100644
index 00000000000..e663052d8b4
--- /dev/null
+++ b/changelogs/unreleased/pipelines-spec.yml
@@ -0,0 +1,5 @@
+---
+title: angelog Replace let! with let_it_be in pipelines spec
+merge_request: 31916
+author: Rajendra Kadam
+type: fixed
diff --git a/changelogs/unreleased/update-deprecated-slot-syntax-in---app-assets-javascripts-ide-components-.yml b/changelogs/unreleased/update-deprecated-slot-syntax-in---javascripts-ide-ide_tree-vue.yml
index 7bac2a1c6b3..7bac2a1c6b3 100644
--- a/changelogs/unreleased/update-deprecated-slot-syntax-in---app-assets-javascripts-ide-components-.yml
+++ b/changelogs/unreleased/update-deprecated-slot-syntax-in---javascripts-ide-ide_tree-vue.yml
diff --git a/changelogs/unreleased/user-api-spec.yml b/changelogs/unreleased/user-api-spec.yml
new file mode 100644
index 00000000000..06f1b5acd24
--- /dev/null
+++ b/changelogs/unreleased/user-api-spec.yml
@@ -0,0 +1,5 @@
+---
+title: Replace let! with let_it_be in user api spec
+merge_request: 31901
+author: Rajendra Kadam
+type: fixed
diff --git a/doc/administration/packages/container_registry.md b/doc/administration/packages/container_registry.md
index 14ae0c3e8c6..f0d4d216d8e 100644
--- a/doc/administration/packages/container_registry.md
+++ b/doc/administration/packages/container_registry.md
@@ -526,7 +526,7 @@ on how to achieve that.
NOTE: **Note:**
In using an external container registry, some features associated with the
-container registry may be unavailable or have [inherant risks](./../../user/packages/container_registry/index.md#use-with-external-container-registries)
+container registry may be unavailable or have [inherent risks](./../../user/packages/container_registry/index.md#use-with-external-container-registries)
**Omnibus GitLab**
diff --git a/doc/administration/raketasks/storage.md b/doc/administration/raketasks/storage.md
index 44592260882..30f50c24138 100644
--- a/doc/administration/raketasks/storage.md
+++ b/doc/administration/raketasks/storage.md
@@ -1,221 +1,162 @@
# Repository storage Rake tasks **(CORE ONLY)**
-This is a collection of Rake tasks you can use to help you list and migrate
-existing projects and attachments associated with it from Legacy storage to
-the new Hashed storage type.
+This is a collection of Rake tasks to help you list and migrate
+existing projects and their attachments to the new
+[hashed storage](../repository_storage_types.md) that GitLab
+uses to organize the Git data.
-You can read more about the storage types [here](../repository_storage_types.md).
+## List projects and attachments
-## Migrate existing projects to hashed storage
+The following Rake tasks will list the projects and attachments that are
+available on legacy and hashed storage.
-Before migrating your existing projects, you should
-[enable hashed storage](../repository_storage_types.md#how-to-migrate-to-hashed-storage) for the new projects as well.
+### On legacy storage
-This task will schedule all your existing projects and attachments associated with it to be migrated to the
-**Hashed** storage type:
+To have a summary and then a list of projects and their attachments using legacy storage:
-**Omnibus Installation**
+- **Omnibus installation**
-```shell
-sudo gitlab-rake gitlab:storage:migrate_to_hashed
-```
+ ```shell
+ # Projects
+ sudo gitlab-rake gitlab:storage:legacy_projects
+ sudo gitlab-rake gitlab:storage:list_legacy_projects
-**Source Installation**
+ # Attachments
+ sudo gitlab-rake gitlab:storage:legacy_attachments
+ sudo gitlab-rake gitlab:storage:list_legacy_attachments
+ ```
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:migrate_to_hashed RAILS_ENV=production
-```
+- **Source installation**
-They both also accept a range as environment variable:
+ ```shell
+ # Projects
+ sudo -u git -H bundle exec rake gitlab:storage:legacy_projects RAILS_ENV=production
+ sudo -u git -H bundle exec rake gitlab:storage:list_legacy_projects RAILS_ENV=production
-```shell
-# to migrate any non migrated project from ID 20 to 50.
-export ID_FROM=20
-export ID_TO=50
-```
+ # Attachments
+ sudo -u git -H bundle exec rake gitlab:storage:legacy_attachments RAILS_ENV=production
+ sudo -u git -H bundle exec rake gitlab:storage:list_legacy_attachments RAILS_ENV=production
+ ```
-You can monitor the progress in the **{admin}** **Admin Area > Monitoring > Background Jobs** page.
-There is a specific queue you can watch to see how long it will take to finish:
-`hashed_storage:hashed_storage_project_migrate`.
+### On hashed storage
-After it reaches zero, you can confirm every project has been migrated by running the commands bellow.
-If you find it necessary, you can run this migration script again to schedule missing projects.
+To have a summary and then a list of projects and their attachments using hashed storage:
-Any error or warning will be logged in Sidekiq's log file.
+- **Omnibus installation**
-NOTE: **Note:**
-If [Geo](../geo/replication/index.md) is enabled, each project that is successfully migrated
-generates an event to replicate the changes on any **secondary** nodes.
+ ```shell
+ # Projects
+ sudo gitlab-rake gitlab:storage:hashed_projects
+ sudo gitlab-rake gitlab:storage:list_hashed_projects
-You only need the `gitlab:storage:migrate_to_hashed` Rake task to migrate your repositories, but we have additional
-commands below that helps you inspect projects and attachments in both legacy and hashed storage.
+ # Attachments
+ sudo gitlab-rake gitlab:storage:hashed_attachments
+ sudo gitlab-rake gitlab:storage:list_hashed_attachments
+ ```
-## Rollback from hashed storage to legacy storage
+- **Source installation**
-If you need to rollback the storage migration for any reason, you can follow the steps described here.
+ ```shell
+ # Projects
+ sudo -u git -H bundle exec rake gitlab:storage:hashed_projects RAILS_ENV=production
+ sudo -u git -H bundle exec rake gitlab:storage:list_hashed_projects RAILS_ENV=production
-NOTE: **Note:**
-Hashed storage will be required in future version of GitLab.
+ # Attachments
+ sudo -u git -H bundle exec rake gitlab:storage:hashed_attachments RAILS_ENV=production
+ sudo -u git -H bundle exec rake gitlab:storage:list_hashed_attachments RAILS_ENV=production
+ ```
-To prevent new projects from being created in the Hashed storage,
-you need to undo the [enable hashed storage](../repository_storage_types.md#how-to-migrate-to-hashed-storage) changes.
+## Migrate to hashed storage
-This task will schedule all your existing projects and associated attachments to be rolled back to the
-Legacy storage type.
+NOTE: **Note:**
+In GitLab 13.0, [hashed storage](../repository_storage_types.md#hashed-storage)
+is enabled by default and the legacy storage is deprecated.
+Support for legacy storage will be removed in GitLab 14.0. If you're on GitLab
+13.0 and later, switching new projects to legacy storage is not possible.
+The option to choose between hashed and legacy storage in the admin area has
+been disabled.
-For Omnibus installations, run the following:
+This task will schedule all your existing projects and attachments associated
+with it to be migrated to the **Hashed** storage type:
-```shell
-sudo gitlab-rake gitlab:storage:rollback_to_legacy
-```
+- **Omnibus installation**
-For source installations, run the following:
+ ```shell
+ sudo gitlab-rake gitlab:storage:migrate_to_hashed
+ ```
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:rollback_to_legacy RAILS_ENV=production
-```
+- **Source installation**
-Both commands accept a range as environment variable:
+ ```shell
+ sudo -u git -H bundle exec rake gitlab:storage:migrate_to_hashed RAILS_ENV=production
+ ```
+
+If you have any existing integration, you may want to do a small rollout first,
+to validate. You can do so by specifying an ID range with the operation by using
+the environment variables `ID_FROM` and `ID_TO`. For example, to limit the rollout
+to project IDs 50 to 100 in an Omnibus GitLab installation:
```shell
-# to rollback any migrated project from ID 20 to 50.
-export ID_FROM=20
-export ID_TO=50
+sudo gitlab-rake gitlab:storage:migrate_to_hashed ID_FROM=50 ID_TO=100
```
You can monitor the progress in the **{admin}** **Admin Area > Monitoring > Background Jobs** page.
-On the **Queues** tab, you can watch the `hashed_storage:hashed_storage_project_rollback` queue to see how long the process will take to finish.
+There is a specific queue you can watch to see how long it will take to finish:
+`hashed_storage:hashed_storage_project_migrate`.
-After it reaches zero, you can confirm every project has been rolled back by running the commands bellow.
-If some projects weren't rolled back, you can run this rollback script again to schedule further rollbacks.
+After it reaches zero, you can confirm every project has been migrated by running the commands bellow.
+If you find it necessary, you can run this migration script again to schedule missing projects.
Any error or warning will be logged in Sidekiq's log file.
-## List projects
-
-The following are Rake tasks for listing projects.
-
-### List projects on legacy storage
-
-To have a simple summary of projects using legacy storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:legacy_projects
-```
-
-**Source Installation**
-
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:legacy_projects RAILS_ENV=production
-```
-
-To list projects using legacy storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:list_legacy_projects
-```
-
-**Source Installation**
-
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:list_legacy_projects RAILS_ENV=production
-
-```
-
-### List projects on hashed storage
-
-To have a simple summary of projects using hashed storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:hashed_projects
-```
-
-**Source Installation**
-
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:hashed_projects RAILS_ENV=production
-```
-
-To list projects using hashed storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:list_hashed_projects
-```
-
-**Source Installation**
-
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:list_hashed_projects RAILS_ENV=production
-```
-
-## List attachments
-
-The following are Rake tasks for listing attachments.
-
-### List attachments on legacy storage
-
-To have a simple summary of project attachments using legacy storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:legacy_attachments
-```
-
-**Source Installation**
-
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:legacy_attachments RAILS_ENV=production
-```
+NOTE: **Note:**
+If [Geo](../geo/replication/index.md) is enabled, each project that is successfully migrated
+generates an event to replicate the changes on any **secondary** nodes.
-To list project attachments using legacy storage:
+You only need the `gitlab:storage:migrate_to_hashed` Rake task to migrate your repositories, but we have additional
+commands below that helps you inspect projects and attachments in both legacy and hashed storage.
-**Omnibus Installation**
+## Rollback from hashed storage to legacy storage
-```shell
-sudo gitlab-rake gitlab:storage:list_legacy_attachments
-```
+NOTE: **Deprecated:**
+In GitLab 13.0, [hashed storage](../repository_storage_types.md#hashed-storage)
+is enabled by default and the legacy storage is deprecated.
+Support for legacy storage will be removed in GitLab 14.0. If you're on GitLab
+13.0 and later, switching new projects to legacy storage is not possible.
+The option to choose between hashed and legacy storage in the admin area has
+been disabled.
-**Source Installation**
+This task will schedule all your existing projects and associated attachments to be rolled back to the
+legacy storage type.
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:list_legacy_attachments RAILS_ENV=production
-```
+- **Omnibus installation**
-### List attachments on hashed storage
+ ```shell
+ sudo gitlab-rake gitlab:storage:rollback_to_legacy
+ ```
-To have a simple summary of project attachments using hashed storage:
+- **Source installation**
-**Omnibus Installation**
+ ```shell
+ sudo -u git -H bundle exec rake gitlab:storage:rollback_to_legacy RAILS_ENV=production
+ ```
-```shell
-sudo gitlab-rake gitlab:storage:hashed_attachments
-```
-
-**Source Installation**
+If you have any existing integration, you may want to do a small rollback first,
+to validate. You can do so by specifying an ID range with the operation by using
+the environment variables `ID_FROM` and `ID_TO`. For example, to limit the rollout
+to project IDs 50 to 100 in an Omnibus GitLab installation:
```shell
-sudo -u git -H bundle exec rake gitlab:storage:hashed_attachments RAILS_ENV=production
+sudo gitlab-rake gitlab:storage:rollback_to_legacy ID_FROM=50 ID_TO=100
```
-To list project attachments using hashed storage:
-
-**Omnibus Installation**
-
-```shell
-sudo gitlab-rake gitlab:storage:list_hashed_attachments
-```
+You can monitor the progress in the **{admin}** **Admin Area > Monitoring > Background Jobs** page.
+On the **Queues** tab, you can watch the `hashed_storage:hashed_storage_project_rollback` queue to see how long the process will take to finish.
-**Source Installation**
+After it reaches zero, you can confirm every project has been rolled back by running the commands bellow.
+If some projects weren't rolled back, you can run this rollback script again to schedule further rollbacks.
+Any error or warning will be logged in Sidekiq's log file.
-```shell
-sudo -u git -H bundle exec rake gitlab:storage:list_hashed_attachments RAILS_ENV=production
-```
+If you have a Geo setup, the rollback will not be reflected automatically
+on the **secondary** node. You may need to wait for a backfill operation to kick-in and remove
+the remaining repositories from the special `@hashed/` folder manually.
diff --git a/doc/administration/repository_storage_types.md b/doc/administration/repository_storage_types.md
index e285e938bfc..a95178c01e2 100644
--- a/doc/administration/repository_storage_types.md
+++ b/doc/administration/repository_storage_types.md
@@ -1,9 +1,8 @@
-# Repository Storage Types
+# Repository storage types **(CORE ONLY)**
-> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/28283) in GitLab 10.0.
-
-Two different storage layouts can be used
-to store the repositories on disk and their characteristics.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/28283) in GitLab 10.0.
+> - Hashed storage became the default for new installations in GitLab 12.0
+> - Hashed storage is enabled by default for new and renamed projects in GitLab 13.0.
GitLab can be configured to use one or multiple repository storage paths/shard
locations that can be:
@@ -20,40 +19,17 @@ The `default` repository shard that is available in any installations
that haven't customized it, points to the local folder: `/var/opt/gitlab/git-data`.
Anything discussed below is expected to be part of that folder.
-## Legacy Storage
-
-Legacy Storage is the storage behavior prior to version 10.0. For historical
-reasons, GitLab replicated the same mapping structure from the projects URLs:
-
-- Project's repository: `#{namespace}/#{project_name}.git`
-- Project's wiki: `#{namespace}/#{project_name}.wiki.git`
-
-This structure made it simple to migrate from existing solutions to GitLab and
-easy for Administrators to find where the repository is stored.
-
-On the other hand this has some drawbacks:
-
-Storage location will concentrate huge amount of top-level namespaces. The
-impact can be reduced by the introduction of
-[multiple storage paths](repository_storage_paths.md).
-
-Because backups are a snapshot of the same URL mapping, if you try to recover a
-very old backup, you need to verify whether any project has taken the place of
-an old removed or renamed project sharing the same URL. This means that
-`mygroup/myproject` from your backup may not be the same original project that
-is at that same URL today.
-
-Any change in the URL will need to be reflected on disk (when groups / users or
-projects are renamed). This can add a lot of load in big installations,
-especially if using any type of network based filesystem.
-
-## Hashed Storage
+## Hashed storage
-CAUTION: **Important:**
-Geo requires Hashed Storage since 12.0. If you haven't migrated yet,
-check the [migration instructions](#how-to-migrate-to-hashed-storage) ASAP.
+NOTE: **Note:**
+In GitLab 13.0, hashed storage is enabled by default and the legacy storage is
+deprecated. Support for legacy storage will be removed in GitLab 14.0.
+If you haven't migrated yet, check the
+[migration instructions](raketasks/storage.md#migrate-to-hashed-storage).
+The option to choose between hashed and legacy storage in the admin area has
+been disabled.
-Hashed Storage is the new storage behavior we rolled out with 10.0. Instead
+Hashed storage is the storage behavior we rolled out with 10.0. Instead
of coupling project URL and the folder structure where the repository will be
stored on disk, we are coupling a hash, based on the project's ID. This makes
the folder structure immutable, and therefore eliminates any requirement to
@@ -134,6 +110,11 @@ The output includes the project ID and the project name:
> [Introduced](https://gitlab.com/gitlab-org/gitaly/issues/1606) in GitLab 12.1.
+DANGER: **Danger:**
+Do not run `git prune` or `git gc` in pool repositories! This can
+cause data loss in "real" repositories that depend on the pool in
+question.
+
Forks of public projects are deduplicated by creating a third repository, the
object pool, containing the objects from the source project. Using
`objects/info/alternates`, the source project and forks use the object pool for
@@ -145,71 +126,15 @@ when housekeeping is run on the source project.
"@pools/#{hash[0..1]}/#{hash[2..3]}/#{hash}.git"
```
-DANGER: **Danger:**
-Do not run `git prune` or `git gc` in pool repositories! This can
-cause data loss in "real" repositories that depend on the pool in
-question.
-
-### How to migrate to Hashed Storage
-
-To start a migration, enable Hashed Storage for new projects:
-
-1. Go to **Admin > Settings > Repository** and expand the **Repository Storage** section.
-1. Select the **Use hashed storage paths for newly created and renamed projects** checkbox.
-
-Check if the change breaks any existing integration you may have that
-either runs on the same machine as your repositories are located, or may login to that machine
-to access data (for example, a remote backup solution).
-
-To schedule a complete rollout, see the
-[Rake task documentation for storage migration](raketasks/storage.md#migrate-existing-projects-to-hashed-storage) for instructions.
-
-If you do have any existing integration, you may want to do a small rollout first,
-to validate. You can do so by specifying a range with the operation.
-
-This is an example of how to limit the rollout to Project IDs 50 to 100, running in
-an Omnibus GitLab installation:
+### Hashed storage coverage migration
-```shell
-sudo gitlab-rake gitlab:storage:migrate_to_hashed ID_FROM=50 ID_TO=100
-```
-
-Check the [documentation](raketasks/storage.md#migrate-existing-projects-to-hashed-storage) for additional information and instructions for
-source-based installation.
-
-#### Rollback
-
-Similar to the migration, to disable Hashed Storage for new
-projects:
-
-1. Go to **Admin > Settings > Repository** and expand the **Repository Storage** section.
-1. Uncheck the **Use hashed storage paths for newly created and renamed projects** checkbox.
-
-To schedule a complete rollback, see the
-[Rake task documentation for storage rollback](raketasks/storage.md#rollback-from-hashed-storage-to-legacy-storage) for instructions.
-
-The rollback task also supports specifying a range of Project IDs. Here is an example
-of limiting the rollout to Project IDs 50 to 100, in an Omnibus GitLab installation:
-
-```shell
-sudo gitlab-rake gitlab:storage:rollback_to_legacy ID_FROM=50 ID_TO=100
-```
-
-If you have a Geo setup, please note that the rollback will not be reflected automatically
-on the **secondary** node. You may need to wait for a backfill operation to kick-in and remove
-the remaining repositories from the special `@hashed/` folder manually.
-
-### Hashed Storage coverage
-
-We are incrementally moving every storable object in GitLab to the Hashed
-Storage pattern. You can check the current coverage status below (and also see
-the [issue](https://gitlab.com/gitlab-com/infrastructure/issues/2821)).
-
-Note that things stored in an S3 compatible endpoint will not have the downsides
+Files stored in an S3 compatible endpoint will not have the downsides
mentioned earlier, if they are not prefixed with `#{namespace}/#{project_name}`,
which is true for CI Cache and LFS Objects.
-| Storable Object | Legacy Storage | Hashed Storage | S3 Compatible | GitLab Version |
+In the table below, you can find the coverage of the migration to the hashed storage.
+
+| Storable Object | Legacy storage | Hashed storage | S3 Compatible | GitLab Version |
| --------------- | -------------- | -------------- | ------------- | -------------- |
| Repository | Yes | Yes | - | 10.0 |
| Attachments | Yes | Yes | - | 10.2 |
@@ -222,18 +147,16 @@ which is true for CI Cache and LFS Objects.
| LFS Objects | Yes | Similar | Yes | 10.0 / 10.7 |
| Repository pools| No | Yes | - | 11.6 |
-#### Implementation Details
-
-##### Avatars
+#### Avatars
Each file is stored in a folder with its `id` from the database. The filename is always `avatar.png` for user avatars.
When avatar is replaced, `Upload` model is destroyed and a new one takes place with different `id`.
-##### CI Artifacts
+#### CI artifacts
CI Artifacts are S3 compatible since **9.4** (GitLab Premium), and available in GitLab Core since **10.6**.
-##### LFS Objects
+#### LFS objects
[LFS Objects in GitLab](../topics/git/lfs/index.md) implement a similar
storage pattern using 2 chars, 2 level folders, following Git's own implementation:
@@ -246,3 +169,39 @@ storage pattern using 2 chars, 2 level folders, following Git's own implementati
```
LFS objects are also [S3 compatible](lfs/index.md#storing-lfs-objects-in-remote-object-storage).
+
+## Legacy storage
+
+NOTE: **Deprecated:**
+In GitLab 13.0, hashed storage is enabled by default and the legacy storage is
+deprecated. If you haven't migrated yet, check the
+[migration instructions](raketasks/storage.md#migrate-to-hashed-storage).
+Support for legacy storage will be removed in GitLab 14.0. If you're on GitLab
+13.0 and later, switching new projects to legacy storage is not possible.
+The option to choose between hashed and legacy storage in the admin area has
+been disabled.
+
+Legacy storage is the storage behavior prior to version 10.0. For historical
+reasons, GitLab replicated the same mapping structure from the projects URLs:
+
+- Project's repository: `#{namespace}/#{project_name}.git`
+- Project's wiki: `#{namespace}/#{project_name}.wiki.git`
+
+This structure made it simple to migrate from existing solutions to GitLab and
+easy for Administrators to find where the repository is stored.
+
+On the other hand this has some drawbacks:
+
+Storage location will concentrate huge amount of top-level namespaces. The
+impact can be reduced by the introduction of
+[multiple storage paths](repository_storage_paths.md).
+
+Because backups are a snapshot of the same URL mapping, if you try to recover a
+very old backup, you need to verify whether any project has taken the place of
+an old removed or renamed project sharing the same URL. This means that
+`mygroup/myproject` from your backup may not be the same original project that
+is at that same URL today.
+
+Any change in the URL will need to be reflected on disk (when groups / users or
+projects are renamed). This can add a lot of load in big installations,
+especially if using any type of network based filesystem.
diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql
index 815f9ec470e..3d2d2b47b7e 100644
--- a/doc/api/graphql/reference/gitlab_schema.graphql
+++ b/doc/api/graphql/reference/gitlab_schema.graphql
@@ -946,6 +946,66 @@ type CreateAlertIssuePayload {
}
"""
+Autogenerated input type of CreateAnnotation
+"""
+input CreateAnnotationInput {
+ """
+ A unique identifier for the client performing the mutation.
+ """
+ clientMutationId: String
+
+ """
+ The global id of the cluster to add an annotation to
+ """
+ clusterId: ID
+
+ """
+ The path to a file defining the dashboard on which the annotation should be added
+ """
+ dashboardPath: String!
+
+ """
+ The description of the annotation
+ """
+ description: String!
+
+ """
+ Timestamp indicating ending moment to which the annotation relates
+ """
+ endingAt: Time
+
+ """
+ The global id of the environment to add an annotation to
+ """
+ environmentId: ID
+
+ """
+ Timestamp indicating starting moment to which the annotation relates
+ """
+ startingAt: Time!
+}
+
+"""
+Autogenerated return type of CreateAnnotation
+"""
+type CreateAnnotationPayload {
+ """
+ The created annotation
+ """
+ annotation: MetricsDashboardAnnotation
+
+ """
+ A unique identifier for the client performing the mutation.
+ """
+ clientMutationId: String
+
+ """
+ Errors encountered during execution of the mutation.
+ """
+ errors: [String!]!
+}
+
+"""
Autogenerated input type of CreateBranch
"""
input CreateBranchInput {
@@ -6558,6 +6618,7 @@ type Mutation {
adminSidekiqQueuesDeleteJobs(input: AdminSidekiqQueuesDeleteJobsInput!): AdminSidekiqQueuesDeleteJobsPayload
boardListUpdateLimitMetrics(input: BoardListUpdateLimitMetricsInput!): BoardListUpdateLimitMetricsPayload
createAlertIssue(input: CreateAlertIssueInput!): CreateAlertIssuePayload
+ createAnnotation(input: CreateAnnotationInput!): CreateAnnotationPayload
createBranch(input: CreateBranchInput!): CreateBranchPayload
createDiffNote(input: CreateDiffNoteInput!): CreateDiffNotePayload
createEpic(input: CreateEpicInput!): CreateEpicPayload
diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json
index 577e764d6a1..3d7c701dbea 100644
--- a/doc/api/graphql/reference/gitlab_schema.json
+++ b/doc/api/graphql/reference/gitlab_schema.json
@@ -2550,6 +2550,166 @@
},
{
"kind": "INPUT_OBJECT",
+ "name": "CreateAnnotationInput",
+ "description": "Autogenerated input type of CreateAnnotation",
+ "fields": null,
+ "inputFields": [
+ {
+ "name": "environmentId",
+ "description": "The global id of the environment to add an annotation to",
+ "type": {
+ "kind": "SCALAR",
+ "name": "ID",
+ "ofType": null
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "clusterId",
+ "description": "The global id of the cluster to add an annotation to",
+ "type": {
+ "kind": "SCALAR",
+ "name": "ID",
+ "ofType": null
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "startingAt",
+ "description": "Timestamp indicating starting moment to which the annotation relates",
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "Time",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "endingAt",
+ "description": "Timestamp indicating ending moment to which the annotation relates",
+ "type": {
+ "kind": "SCALAR",
+ "name": "Time",
+ "ofType": null
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "dashboardPath",
+ "description": "The path to a file defining the dashboard on which the annotation should be added",
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "description",
+ "description": "The description of the annotation",
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ },
+ {
+ "name": "clientMutationId",
+ "description": "A unique identifier for the client performing the mutation.",
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "defaultValue": null
+ }
+ ],
+ "interfaces": null,
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "CreateAnnotationPayload",
+ "description": "Autogenerated return type of CreateAnnotation",
+ "fields": [
+ {
+ "name": "annotation",
+ "description": "The created annotation",
+ "args": [
+
+ ],
+ "type": {
+ "kind": "OBJECT",
+ "name": "MetricsDashboardAnnotation",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "clientMutationId",
+ "description": "A unique identifier for the client performing the mutation.",
+ "args": [
+
+ ],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "errors",
+ "description": "Errors encountered during execution of the mutation.",
+ "args": [
+
+ ],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [
+
+ ],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "INPUT_OBJECT",
"name": "CreateBranchInput",
"description": "Autogenerated input type of CreateBranch",
"fields": null,
@@ -18570,6 +18730,33 @@
"deprecationReason": null
},
{
+ "name": "createAnnotation",
+ "description": null,
+ "args": [
+ {
+ "name": "input",
+ "description": null,
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "INPUT_OBJECT",
+ "name": "CreateAnnotationInput",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "type": {
+ "kind": "OBJECT",
+ "name": "CreateAnnotationPayload",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
"name": "createBranch",
"description": null,
"args": [
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index c88e3a3d9da..e2d18ee3f14 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -175,6 +175,16 @@ Autogenerated return type of CreateAlertIssue
| `errors` | String! => Array | Errors encountered during execution of the mutation. |
| `issue` | Issue | The issue created after mutation |
+## CreateAnnotationPayload
+
+Autogenerated return type of CreateAnnotation
+
+| Name | Type | Description |
+| --- | ---- | ---------- |
+| `annotation` | MetricsDashboardAnnotation | The created annotation |
+| `clientMutationId` | String | A unique identifier for the client performing the mutation. |
+| `errors` | String! => Array | Errors encountered during execution of the mutation. |
+
## CreateBranchPayload
Autogenerated return type of CreateBranch
diff --git a/doc/development/import_export.md b/doc/development/import_export.md
index 40a56679f2f..6d1b6929667 100644
--- a/doc/development/import_export.md
+++ b/doc/development/import_export.md
@@ -339,14 +339,13 @@ Fixtures used in Import/Export specs live in `spec/fixtures/lib/gitlab/import_ex
There are two versions of each of these fixtures:
- A human readable single JSON file with all objects, called either `project.json` or `group.json`.
-- A tree.tar.gz file containing a tree of files in `ndjson` format. **Please do not edit this file manually unless strictly necessary.**
+- A folder named `tree`, containing a tree of files in `ndjson` format. **Please do not edit files under this folder manually unless strictly necessary.**
The tools to generate the NDJSON tree from the human-readable JSON files live in the [`gitlab-org/memory-team/team-tools`](https://gitlab.com/gitlab-org/memory-team/team-tools/-/blob/master/import-export/) project.
### Project
**Please use `legacy-project-json-to-ndjson.sh` to generate the NDJSON tree.**
-Once you're done generating the files, please package them using `tar -czf tree.tar.gz tree` from the same directory as the `tree` directory generated is located.
The NDJSON tree will look like this:
@@ -380,10 +379,7 @@ tree
### Group
-**Please use `legacy-group-json-to-ndjson.rb` to generate the NDJSON tree.** This script can be found in [`gitlab-org/memory-team/team-tools!7`](https://gitlab.com/gitlab-org/memory-team/team-tools/-/merge_requests/7).
-Once this MR is merged, the script will be found in the directory mentioned earlier.
-
-Once you're done generating the files, please package them using `tar -czf tree.tar.gz tree` from the same directory as the `tree` directory generated is located.
+**Please use `legacy-group-json-to-ndjson.rb` to generate the NDJSON tree.**
The NDJSON tree will look like this:
@@ -409,4 +405,4 @@ tree
└── 4352.json
```
-CAUTION: **Caution:** When updating these fixtures, please ensure you update the `json` files and the `tar.gz` archives, as the tests apply to both.
+CAUTION: **Caution:** When updating these fixtures, please ensure you update both `json` files and `tree` folder, as the tests apply to both.
diff --git a/doc/development/licensed_feature_availability.md b/doc/development/licensed_feature_availability.md
index 29e4ace157b..4f962b6f5e2 100644
--- a/doc/development/licensed_feature_availability.md
+++ b/doc/development/licensed_feature_availability.md
@@ -35,3 +35,7 @@ the instance license.
```ruby
License.feature_available?(:feature_symbol)
```
+
+## Enabling promo features on GitLab.com
+
+A paid feature can be made available to everyone on GitLab.com by enabling the feature flag `"promo_#{feature}"`.
diff --git a/doc/user/admin_area/settings/index.md b/doc/user/admin_area/settings/index.md
index bc1afea9bb7..761d640c535 100644
--- a/doc/user/admin_area/settings/index.md
+++ b/doc/user/admin_area/settings/index.md
@@ -44,7 +44,7 @@ Access the default page for admin area settings by navigating to
| Option | Description |
| ------ | ----------- |
| [Repository mirror](visibility_and_access_controls.md#allow-mirrors-to-be-set-up-for-projects) | Configure repository mirroring. |
-| [Repository storage](../../../administration/repository_storage_types.md#how-to-migrate-to-hashed-storage) | Configure storage path settings. |
+| [Repository storage](../../../administration/repository_storage_types.md) | Configure storage path settings. |
| Repository maintenance | ([Repository checks](../../../administration/repository_checks.md) and [Housekeeping](../../../administration/housekeeping.md)). Configure automatic Git checks and housekeeping on repositories. |
| [Repository static objects](../../../administration/static_objects_external_storage.md) | Serve repository static objects (for example, archives, blobs, ...) from an external storage (for example, a CDN). |
diff --git a/doc/user/packages/container_registry/index.md b/doc/user/packages/container_registry/index.md
index 55dc048222e..f7a6858c3cb 100644
--- a/doc/user/packages/container_registry/index.md
+++ b/doc/user/packages/container_registry/index.md
@@ -492,7 +492,7 @@ older tags and images are regularly removed from the Container Registry.
NOTE: **Note:**
Expiration policies for projects created before GitLab 12.8 may be enabled by an
admin in the [CI/CD Package Registry settings](./../../admin_area/settings/index.md#cicd).
-Note the inherant [risks involved](./index.md#use-with-external-container-registries).
+Note the inherent [risks involved](./index.md#use-with-external-container-registries).
It is possible to create a per-project expiration policy, so that you can make sure that
older tags and images are regularly removed from the Container Registry.
@@ -542,7 +542,7 @@ See the API documentation for further details: [Edit project](../../../api/proje
### Use with external container registries
When using an [external container registry](./../../../administration/packages/container_registry.md#use-an-external-container-registry-with-gitlab-as-an-auth-endpoint),
-running an experation policy on a project may have some performance risks. If a project is going to run
+running an expiration policy on a project may have some performance risks. If a project is going to run
a policy that will remove large quantities of tags (in the thousands), the GitLab background jobs that
run the policy may get backed up or fail completely. It is recommended you only enable container expiration
policies for projects that were created before GitLab 12.8 if you are confident the amount of tags
@@ -577,3 +577,47 @@ Troubleshooting the GitLab Container Registry, most of the times, requires
administration access to the GitLab server.
[Read how to troubleshoot the Container Registry](../../../administration/packages/container_registry.md#troubleshooting).
+
+### Unable to change path or transfer a project
+
+If you try to change a project's path or transfer a project to a new namespace,
+you may receive one of the following errors:
+
+- "Project cannot be transferred, because tags are present in its container registry."
+- "Namespace cannot be moved because at least one project has tags in container registry."
+
+This issue occurs when the project has images in the Container Registry.
+You must delete or move these images before you can change the path or transfer
+the project.
+
+The following procedure uses these sample project names:
+
+- For the current project: `example.gitlab.com/org/build/sample_project/cr:v2.9.1`
+- For the new project: `example.gitlab.com/new_org/build/new_sample_project/cr:v2.9.1`
+
+Use your own URLs to complete the following steps:
+
+1. Download the Docker images on your computer:
+
+ ```shell
+ docker login example.gitlab.com
+ docker pull example.gitlab.com/org/build/sample_project/cr:v2.9.1
+ ```
+
+1. Rename the images to match the new project name:
+
+ ```shell
+ docker tag example.gitlab.com/org/build/sample_project/cr:v2.9.1 example.gitlab.com/new_org/build/new_sample_project/cr:v2.9.1
+ ```
+
+1. Delete the images in both projects by using the [UI](#delete-images) or [API](../../../api/packages.md#delete-a-project-package).
+ There may be a delay while the images are queued and deleted.
+1. Change the path or transfer the project by going to **Settings > General**
+ and expanding **Advanced**.
+1. Restore the images:
+
+ ```shell
+ docker push example.gitlab.com/new_org/build/new_sample_project/cr:v2.9.1
+ ```
+
+Follow [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/18383) for details.
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb
index e37c1d9d319..68f4a0dcb65 100644
--- a/lib/api/project_snippets.rb
+++ b/lib/api/project_snippets.rb
@@ -55,9 +55,9 @@ module API
success Entities::ProjectSnippet
end
params do
- requires :title, type: String, desc: 'The title of the snippet'
+ requires :title, type: String, allow_blank: false, desc: 'The title of the snippet'
requires :file_name, type: String, desc: 'The file name of the snippet'
- optional :content, type: String, allow_blank: false, desc: 'The content of the snippet'
+ requires :content, type: String, allow_blank: false, desc: 'The content of the snippet'
optional :description, type: String, desc: 'The description of a snippet'
requires :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
@@ -84,7 +84,7 @@ module API
end
params do
requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
- optional :title, type: String, desc: 'The title of the snippet'
+ optional :title, type: String, allow_blank: false, desc: 'The title of the snippet'
optional :file_name, type: String, desc: 'The file name of the snippet'
optional :content, type: String, allow_blank: false, desc: 'The content of the snippet'
optional :description, type: String, desc: 'The description of a snippet'
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb
index b2719f36081..be58b832f97 100644
--- a/lib/api/snippets.rb
+++ b/lib/api/snippets.rb
@@ -65,9 +65,9 @@ module API
success Entities::PersonalSnippet
end
params do
- requires :title, type: String, desc: 'The title of a snippet'
+ requires :title, type: String, allow_blank: false, desc: 'The title of a snippet'
requires :file_name, type: String, desc: 'The name of a snippet file'
- requires :content, type: String, desc: 'The content of a snippet'
+ requires :content, type: String, allow_blank: false, desc: 'The content of a snippet'
optional :description, type: String, desc: 'The description of a snippet'
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
@@ -96,9 +96,9 @@ module API
end
params do
requires :id, type: Integer, desc: 'The ID of a snippet'
- optional :title, type: String, desc: 'The title of a snippet'
+ optional :title, type: String, allow_blank: false, desc: 'The title of a snippet'
optional :file_name, type: String, desc: 'The name of a snippet file'
- optional :content, type: String, desc: 'The content of a snippet'
+ optional :content, type: String, allow_blank: false, desc: 'The content of a snippet'
optional :description, type: String, desc: 'The description of a snippet'
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
diff --git a/lib/gitlab/alerting/notification_payload_parser.rb b/lib/gitlab/alerting/notification_payload_parser.rb
index 1237c575eac..c79d69613f3 100644
--- a/lib/gitlab/alerting/notification_payload_parser.rb
+++ b/lib/gitlab/alerting/notification_payload_parser.rb
@@ -5,8 +5,8 @@ module Gitlab
class NotificationPayloadParser
BadPayloadError = Class.new(StandardError)
- DEFAULT_TITLE = 'New: Incident'.freeze
- DEFAULT_SEVERITY = 'critical'.freeze
+ DEFAULT_TITLE = 'New: Incident'
+ DEFAULT_SEVERITY = 'critical'
def initialize(payload)
@payload = payload.to_h.with_indifferent_access
diff --git a/lib/gitlab/git_access_snippet.rb b/lib/gitlab/git_access_snippet.rb
index 3326b50ae67..70db4271469 100644
--- a/lib/gitlab/git_access_snippet.rb
+++ b/lib/gitlab/git_access_snippet.rb
@@ -106,7 +106,7 @@ module Gitlab
def check_single_change_access(change)
Checks::SnippetCheck.new(change, logger: logger).validate!
- Checks::PushFileCountCheck.new(change, repository: repository, limit: Snippet::MAX_FILE_COUNT, logger: logger).validate!
+ Checks::PushFileCountCheck.new(change, repository: repository, limit: Snippet.max_file_limit(user), logger: logger).validate!
rescue Checks::TimedLogger::TimeoutError
raise TimeoutError, logger.full_message
end
diff --git a/lib/gitlab/sidekiq_logging/structured_logger.rb b/lib/gitlab/sidekiq_logging/structured_logger.rb
index 8699117031d..4e39120f8a7 100644
--- a/lib/gitlab/sidekiq_logging/structured_logger.rb
+++ b/lib/gitlab/sidekiq_logging/structured_logger.rb
@@ -30,6 +30,12 @@ module Gitlab
output_payload.merge!(job.slice(*::Gitlab::InstrumentationHelper::KEYS))
end
+ def add_logging_extras!(job, output_payload)
+ output_payload.merge!(
+ job.select { |key, _| key.to_s.start_with?("#{ApplicationWorker::LOGGING_EXTRA_KEY}.") }
+ )
+ end
+
def log_job_start(payload)
payload['message'] = "#{base_message(payload)}: start"
payload['job_status'] = 'start'
@@ -43,6 +49,7 @@ module Gitlab
def log_job_done(job, started_time, payload, job_exception = nil)
payload = payload.dup
add_instrumentation_keys!(job, payload)
+ add_logging_extras!(job, payload)
elapsed_time = elapsed(started_time)
add_time_keys!(elapsed_time, payload)
diff --git a/lib/gitlab/sidekiq_middleware.rb b/lib/gitlab/sidekiq_middleware.rb
index 083053c3d44..4eef3fbd12e 100644
--- a/lib/gitlab/sidekiq_middleware.rb
+++ b/lib/gitlab/sidekiq_middleware.rb
@@ -14,6 +14,7 @@ module Gitlab
chain.add ::Gitlab::SidekiqMiddleware::ArgumentsLogger if arguments_logger
chain.add ::Gitlab::SidekiqMiddleware::MemoryKiller if memory_killer
chain.add ::Gitlab::SidekiqMiddleware::RequestStoreMiddleware
+ chain.add ::Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata
chain.add ::Gitlab::SidekiqMiddleware::BatchLoader
chain.add ::Labkit::Middleware::Sidekiq::Server
chain.add ::Gitlab::SidekiqMiddleware::InstrumentationLogger
diff --git a/lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb b/lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb
new file mode 100644
index 00000000000..93c3131d50e
--- /dev/null
+++ b/lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module SidekiqMiddleware
+ class ExtraDoneLogMetadata
+ def call(worker, job, queue)
+ yield
+
+ # We needed a way to pass state from a worker in to the
+ # Gitlab::SidekiqLogging::StructuredLogger . Unfortunately the
+ # StructuredLogger itself is not a middleware so cannot access the
+ # worker object. We also tried to use SafeRequestStore but to pass the
+ # data up but that doesn't work either because this is reset in
+ # Gitlab::SidekiqMiddleware::RequestStoreMiddleware inside yield for
+ # the StructuredLogger so it's cleared before we get to logging the
+ # done statement. As such the only way to do this is to pass the data
+ # up in the `job` object. Since `job` is just a Hash we can add this
+ # extra metadata there.
+ if worker.respond_to?(:logging_extras)
+ job.merge!(worker.logging_extras)
+ end
+ end
+ end
+ end
+end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index fdcc4d5c5cc..60070216460 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -1748,6 +1748,9 @@ msgstr ""
msgid "AlertManagement|Alert detail"
msgstr ""
+msgid "AlertManagement|Alert details"
+msgstr ""
+
msgid "AlertManagement|Alerts"
msgstr ""
@@ -1772,9 +1775,6 @@ msgstr ""
msgid "AlertManagement|Events"
msgstr ""
-msgid "AlertManagement|Full alert details"
-msgstr ""
-
msgid "AlertManagement|High"
msgstr ""
@@ -1790,6 +1790,9 @@ msgstr ""
msgid "AlertManagement|More information"
msgstr ""
+msgid "AlertManagement|No alert data to display."
+msgstr ""
+
msgid "AlertManagement|No alerts available to display. If you think you're seeing this message in error, refresh the page."
msgstr ""
diff --git a/spec/frontend/alert_management/components/alert_management_detail_spec.js b/spec/frontend/alert_management/components/alert_management_detail_spec.js
index 865083c1183..1e4c2e24ccb 100644
--- a/spec/frontend/alert_management/components/alert_management_detail_spec.js
+++ b/spec/frontend/alert_management/components/alert_management_detail_spec.js
@@ -1,5 +1,5 @@
import { mount, shallowMount } from '@vue/test-utils';
-import { GlAlert, GlLoadingIcon, GlDropdownItem } from '@gitlab/ui';
+import { GlAlert, GlLoadingIcon, GlDropdownItem, GlTable } from '@gitlab/ui';
import AlertDetails from '~/alert_management/components/alert_details.vue';
import updateAlertStatus from '~/alert_management/graphql/mutations/update_alert_status.graphql';
import createFlash from '~/flash';
@@ -13,6 +13,7 @@ describe('AlertDetails', () => {
let wrapper;
const newIssuePath = 'root/alerts/-/issues/new';
const findStatusDropdownItem = () => wrapper.find(GlDropdownItem);
+ const findDetailsTable = () => wrapper.find(GlTable);
function mountComponent({
data,
@@ -133,9 +134,12 @@ describe('AlertDetails', () => {
});
describe('View full alert details', () => {
- it('should display a unstyled list of alert details', () => {
+ beforeEach(() => {
+ mountComponent({ data: { alert: mockAlert } });
+ });
+ it('should display a table of raw alert details data', () => {
wrapper.find('[data-testid="fullDetailsTab"]').trigger('click');
- expect(wrapper.find('.list-unstyled').exists()).toBe(true);
+ expect(findDetailsTable().exists()).toBe(true);
});
});
diff --git a/spec/lib/gitlab/checks/push_file_count_check_spec.rb b/spec/lib/gitlab/checks/push_file_count_check_spec.rb
index 58ba7d579a3..e05102a9ce8 100644
--- a/spec/lib/gitlab/checks/push_file_count_check_spec.rb
+++ b/spec/lib/gitlab/checks/push_file_count_check_spec.rb
@@ -8,7 +8,7 @@ describe Gitlab::Checks::PushFileCountCheck do
let(:timeout) { Gitlab::GitAccess::INTERNAL_TIMEOUT }
let(:logger) { Gitlab::Checks::TimedLogger.new(timeout: timeout) }
- subject { described_class.new(changes, repository: snippet.repository, limit: 1, logger: logger) }
+ subject { described_class.new(changes, repository: snippet.repository, limit: 2, logger: logger) }
describe '#validate!' do
using RSpec::Parameterized::TableSyntax
@@ -31,7 +31,7 @@ describe Gitlab::Checks::PushFileCountCheck do
where(:old, :new, :valid, :message) do
'single-file' | 'edit-file' | true | nil
- 'single-file' | 'multiple-files' | false | 'The repository can contain at most 1 file(s).'
+ 'single-file' | 'multiple-files' | false | 'The repository can contain at most 2 file(s).'
'single-file' | 'no-files' | false | 'The repository must contain at least 1 file.'
'edit-file' | 'rename-and-edit-file' | true | nil
end
diff --git a/spec/lib/gitlab/git_access_snippet_spec.rb b/spec/lib/gitlab/git_access_snippet_spec.rb
index 7ecfa4e519d..48b425a8ec5 100644
--- a/spec/lib/gitlab/git_access_snippet_spec.rb
+++ b/spec/lib/gitlab/git_access_snippet_spec.rb
@@ -278,6 +278,16 @@ describe Gitlab::GitAccessSnippet do
expect { push_access_check }.to raise_forbidden('foo')
end
+
+ it 'sets the file count limit from Snippet class' do
+ service = double
+
+ expect(service).to receive(:validate!).and_return(nil)
+ expect(Snippet).to receive(:max_file_limit).with(user).and_return(5)
+ expect(Gitlab::Checks::PushFileCountCheck).to receive(:new).with(anything, hash_including(limit: 5)).and_return(service)
+
+ push_access_check
+ end
end
it_behaves_like 'snippet checks'
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index 4a1c046a603..a4bbb51baae 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -218,6 +218,27 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
subject.call(job, 'test_queue') { }
end
end
+
+ context 'when there is extra metadata set for the done log' do
+ let(:expected_start_payload) { start_payload.except('args') }
+
+ let(:expected_end_payload) do
+ end_payload.except('args').merge("#{ApplicationWorker::LOGGING_EXTRA_KEY}.key1" => 15, "#{ApplicationWorker::LOGGING_EXTRA_KEY}.key2" => 16)
+ end
+
+ it 'logs it in the done log' do
+ Timecop.freeze(timestamp) do
+ expect(logger).to receive(:info).with(expected_start_payload).ordered
+ expect(logger).to receive(:info).with(expected_end_payload).ordered
+
+ subject.call(job, 'test_queue') do
+ job["#{ApplicationWorker::LOGGING_EXTRA_KEY}.key1"] = 15
+ job["#{ApplicationWorker::LOGGING_EXTRA_KEY}.key2"] = 16
+ job['key that will be ignored because it does not start with extra.'] = 17
+ end
+ end
+ end
+ end
end
describe '#add_time_keys!' do
diff --git a/spec/lib/gitlab/sidekiq_middleware/extra_done_log_metadata_spec.rb b/spec/lib/gitlab/sidekiq_middleware/extra_done_log_metadata_spec.rb
new file mode 100644
index 00000000000..98847885e62
--- /dev/null
+++ b/spec/lib/gitlab/sidekiq_middleware/extra_done_log_metadata_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata do
+ # Cannot use Class.new for this as ApplicationWorker will need the class to
+ # have a name during `included do`.
+ let(:worker) { AdminEmailWorker.new }
+
+ let(:worker_without_application_worker) do
+ Class.new do
+ end.new
+ end
+
+ subject { described_class.new }
+
+ let(:job) { { 'jid' => 123 } }
+ let(:queue) { 'test_queue' }
+
+ describe '#call' do
+ it 'merges Application#logging_extras in to job' do
+ worker.log_extra_metadata_on_done(:key1, 15)
+ worker.log_extra_metadata_on_done(:key2, 16)
+ expect { |b| subject.call(worker, job, queue, &b) }.to yield_control
+
+ expect(job).to eq({ 'jid' => 123, 'extra.admin_email_worker.key1' => 15, 'extra.admin_email_worker.key2' => 16 })
+ end
+
+ it 'does not raise when the worker does not respond to #done_log_extra_metadata' do
+ expect { |b| subject.call(worker_without_application_worker, job, queue, &b) }.to yield_control
+
+ expect(job).to eq({ 'jid' => 123 })
+ end
+ end
+end
diff --git a/spec/lib/gitlab/sidekiq_middleware_spec.rb b/spec/lib/gitlab/sidekiq_middleware_spec.rb
index 8c4cd310bd7..6fe61fb42a5 100644
--- a/spec/lib/gitlab/sidekiq_middleware_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware_spec.rb
@@ -9,6 +9,7 @@ describe Gitlab::SidekiqMiddleware do
TestWorker.class_eval do
include Sidekiq::Worker
+ include ApplicationWorker
def perform(_arg)
Gitlab::SafeRequestStore['gitaly_call_actual'] = 1
@@ -55,6 +56,7 @@ describe Gitlab::SidekiqMiddleware do
Gitlab::SidekiqMiddleware::ArgumentsLogger,
Gitlab::SidekiqMiddleware::MemoryKiller,
Gitlab::SidekiqMiddleware::RequestStoreMiddleware,
+ Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata,
Gitlab::SidekiqMiddleware::WorkerContext::Server,
Gitlab::SidekiqMiddleware::AdminMode::Server,
Gitlab::SidekiqMiddleware::DuplicateJobs::Server
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 12c06feacf3..4d6586c1df4 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -734,4 +734,20 @@ describe Snippet do
it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "#{snippet.project.full_path}/snippets/#{snippet.id}.git") }
end
end
+
+ describe '.max_file_limit' do
+ subject { described_class.max_file_limit(nil) }
+
+ it "returns #{Snippet::MAX_FILE_COUNT}" do
+ expect(subject).to eq Snippet::MAX_FILE_COUNT
+ end
+
+ context 'when feature flag :snippet_multiple_files is disabled' do
+ it "returns #{described_class::MAX_SINGLE_FILE_COUNT}" do
+ stub_feature_flags(snippet_multiple_files: false)
+
+ expect(subject).to eq described_class::MAX_SINGLE_FILE_COUNT
+ end
+ end
+ end
end
diff --git a/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb b/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb
new file mode 100644
index 00000000000..8568dc8ffc0
--- /dev/null
+++ b/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb
@@ -0,0 +1,231 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Mutations::Metrics::Dashboard::Annotations::Create do
+ include GraphqlHelpers
+
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:project) { create(:project, :private, :repository) }
+ let_it_be(:environment) { create(:environment, project: project) }
+ let_it_be(:cluster) { create(:cluster, projects: [project]) }
+ let(:dashboard_path) { 'config/prometheus/common_metrics.yml' }
+ let(:starting_at) { Time.current.iso8601 }
+ let(:ending_at) { 1.hour.from_now.iso8601 }
+ let(:description) { 'test description' }
+
+ def mutation_response
+ graphql_mutation_response(:create_annotation)
+ end
+
+ specify { expect(described_class).to require_graphql_authorizations(:create_metrics_dashboard_annotation) }
+
+ context 'when annotation source is environment' do
+ let(:mutation) do
+ variables = {
+ environment_id: GitlabSchema.id_from_object(environment).to_s,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ context 'when the user does not have permission' do
+ before do
+ project.add_reporter(current_user)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors',
+ errors: [Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR]
+
+ it 'does not create the annotation' do
+ expect do
+ post_graphql_mutation(mutation, current_user: current_user)
+ end.not_to change { Metrics::Dashboard::Annotation.count }
+ end
+ end
+
+ context 'when the user has permission' do
+ before do
+ project.add_developer(current_user)
+ end
+
+ it 'creates the annotation' do
+ expect do
+ post_graphql_mutation(mutation, current_user: current_user)
+ end.to change { Metrics::Dashboard::Annotation.count }.by(1)
+ end
+
+ it 'returns the created annotation' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ annotation = Metrics::Dashboard::Annotation.first
+ annotation_id = GitlabSchema.id_from_object(annotation).to_s
+
+ expect(mutation_response['annotation']['description']).to match(description)
+ expect(mutation_response['annotation']['startingAt'].to_time).to match(starting_at.to_time)
+ expect(mutation_response['annotation']['endingAt'].to_time).to match(ending_at.to_time)
+ expect(mutation_response['annotation']['id']).to match(annotation_id)
+ expect(annotation.environment_id).to eq(environment.id)
+ end
+
+ context 'when environment_id is missing' do
+ let(:mutation) do
+ variables = {
+ environment_id: nil,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::ANNOTATION_SOURCE_ARGUMENT_ERROR]
+ end
+
+ context 'when environment_id is invalid' do
+ let(:mutation) do
+ variables = {
+ environment_id: 'invalid_id',
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: ['invalid_id is not a valid GitLab id.']
+ end
+ end
+ end
+
+ context 'when annotation source is cluster' do
+ let(:mutation) do
+ variables = {
+ cluster_id: GitlabSchema.id_from_object(cluster).to_s,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ context 'with permission' do
+ before do
+ project.add_developer(current_user)
+ end
+
+ it 'creates the annotation' do
+ expect do
+ post_graphql_mutation(mutation, current_user: current_user)
+ end.to change { Metrics::Dashboard::Annotation.count }.by(1)
+ end
+
+ it 'returns the created annotation' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ annotation = Metrics::Dashboard::Annotation.first
+ annotation_id = GitlabSchema.id_from_object(annotation).to_s
+
+ expect(mutation_response['annotation']['description']).to match(description)
+ expect(mutation_response['annotation']['startingAt'].to_time).to match(starting_at.to_time)
+ expect(mutation_response['annotation']['endingAt'].to_time).to match(ending_at.to_time)
+ expect(mutation_response['annotation']['id']).to match(annotation_id)
+ expect(annotation.cluster_id).to eq(cluster.id)
+ end
+
+ context 'when cluster_id is missing' do
+ let(:mutation) do
+ variables = {
+ cluster_id: nil,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::ANNOTATION_SOURCE_ARGUMENT_ERROR]
+ end
+ end
+
+ context 'without permission' do
+ before do
+ project.add_guest(current_user)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors',
+ errors: [Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR]
+
+ it 'does not create the annotation' do
+ expect do
+ post_graphql_mutation(mutation, current_user: current_user)
+ end.not_to change { Metrics::Dashboard::Annotation.count }
+ end
+ end
+
+ context 'when cluster_id is invalid' do
+ let(:mutation) do
+ variables = {
+ cluster_id: 'invalid_id',
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: ['invalid_id is not a valid GitLab id.']
+ end
+ end
+
+ context 'when both environment_id and cluster_id are provided' do
+ let(:mutation) do
+ variables = {
+ environment_id: GitlabSchema.id_from_object(environment).to_s,
+ cluster_id: GitlabSchema.id_from_object(cluster).to_s,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::ANNOTATION_SOURCE_ARGUMENT_ERROR]
+ end
+
+ context 'when a non-cluster or environment id is provided' do
+ let(:mutation) do
+ variables = {
+ environment_id: GitlabSchema.id_from_object(project).to_s,
+ starting_at: starting_at,
+ ending_at: ending_at,
+ dashboard_path: dashboard_path,
+ description: description
+ }
+
+ graphql_mutation(:create_annotation, variables)
+ end
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::INVALID_ANNOTATION_SOURCE_ERROR]
+ end
+end
diff --git a/spec/requests/api/graphql/project/alert_management/alerts_spec.rb b/spec/requests/api/graphql/project/alert_management/alerts_spec.rb
index 209ac850212..c226e659364 100644
--- a/spec/requests/api/graphql/project/alert_management/alerts_spec.rb
+++ b/spec/requests/api/graphql/project/alert_management/alerts_spec.rb
@@ -92,6 +92,15 @@ describe 'getting Alert Management Alerts' do
it { expect(first_alert['iid']).to eq(resolved_alert.iid.to_s) }
end
+ context 'with statuses given' do
+ let(:params) { 'statuses: [TRIGGERED, ACKNOWLEDGED]' }
+
+ it_behaves_like 'a working graphql query'
+
+ it { expect(alerts.size).to eq(1) }
+ it { expect(first_alert['iid']).to eq(triggered_alert.iid.to_s) }
+ end
+
context 'sorting data given' do
let(:params) { 'sort: SEVERITY_DESC' }
let(:iids) { alerts.map { |a| a['iid'] } }
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 8ab8207bc49..14b22de9661 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -795,8 +795,8 @@ describe API::MergeRequests do
end
describe "GET /groups/:id/merge_requests" do
- let!(:group) { create(:group, :public) }
- let!(:project) { create(:project, :public, :repository, creator: user, namespace: group, only_allow_merge_if_pipeline_succeeds: false) }
+ let_it_be(:group) { create(:group, :public) }
+ let_it_be(:project) { create(:project, :public, :repository, creator: user, namespace: group, only_allow_merge_if_pipeline_succeeds: false) }
let(:endpoint_path) { "/groups/#{group.id}/merge_requests" }
before do
@@ -806,9 +806,9 @@ describe API::MergeRequests do
it_behaves_like 'merge requests list'
context 'when have subgroups' do
- let!(:group) { create(:group, :public) }
- let!(:subgroup) { create(:group, parent: group) }
- let!(:project) { create(:project, :public, :repository, creator: user, namespace: subgroup, only_allow_merge_if_pipeline_succeeds: false) }
+ let_it_be(:group) { create(:group, :public) }
+ let_it_be(:subgroup) { create(:group, parent: group) }
+ let_it_be(:project) { create(:project, :public, :repository, creator: user, namespace: subgroup, only_allow_merge_if_pipeline_succeeds: false) }
it_behaves_like 'merge requests list'
end
@@ -1554,7 +1554,7 @@ describe API::MergeRequests do
end
context 'forked projects', :sidekiq_might_not_need_inline do
- let!(:user2) { create(:user) }
+ let_it_be(:user2) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let!(:forked_project) { fork_project(project, user2, repository: true) }
let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) }
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index e659ff81a3d..f57223f1de5 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -72,8 +72,8 @@ describe API::Pipelines do
end
context 'when scope is branches or tags' do
- let!(:pipeline_branch) { create(:ci_pipeline, project: project) }
- let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) }
+ let_it_be(:pipeline_branch) { create(:ci_pipeline, project: project) }
+ let_it_be(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) }
context 'when scope is branches' do
it 'returns matched pipelines' do
@@ -161,7 +161,7 @@ describe API::Pipelines do
end
context 'when name is specified' do
- let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
context 'when name exists' do
it 'returns matched pipelines' do
@@ -185,7 +185,7 @@ describe API::Pipelines do
end
context 'when username is specified' do
- let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
context 'when username exists' do
it 'returns matched pipelines' do
@@ -209,8 +209,8 @@ describe API::Pipelines do
end
context 'when yaml_errors is specified' do
- let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') }
- let!(:pipeline2) { create(:ci_pipeline, project: project) }
+ let_it_be(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') }
+ let_it_be(:pipeline2) { create(:ci_pipeline, project: project) }
context 'when yaml_errors is true' do
it 'returns matched pipelines' do
@@ -242,9 +242,9 @@ describe API::Pipelines do
end
context 'when updated_at filters are specified' do
- let!(:pipeline1) { create(:ci_pipeline, project: project, updated_at: 2.days.ago) }
- let!(:pipeline2) { create(:ci_pipeline, project: project, updated_at: 4.days.ago) }
- let!(:pipeline3) { create(:ci_pipeline, project: project, updated_at: 1.hour.ago) }
+ let_it_be(:pipeline1) { create(:ci_pipeline, project: project, updated_at: 2.days.ago) }
+ let_it_be(:pipeline2) { create(:ci_pipeline, project: project, updated_at: 4.days.ago) }
+ let_it_be(:pipeline3) { create(:ci_pipeline, project: project, updated_at: 1.hour.ago) }
it 'returns pipelines with last update date in specified datetime range' do
get api("/projects/#{project.id}/pipelines", user), params: { updated_before: 1.day.ago, updated_after: 3.days.ago }
@@ -614,7 +614,7 @@ describe API::Pipelines do
end
context 'when the pipeline has jobs' do
- let!(:build) { create(:ci_build, project: project, pipeline: pipeline) }
+ let_it_be(:build) { create(:ci_build, project: project, pipeline: pipeline) }
it 'destroys associated jobs' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
@@ -654,12 +654,12 @@ describe API::Pipelines do
describe 'POST /projects/:id/pipelines/:pipeline_id/retry' do
context 'authorized user' do
- let!(:pipeline) do
+ let_it_be(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch)
end
- let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
+ let_it_be(:build) { create(:ci_build, :failed, pipeline: pipeline) }
it 'retries failed builds' do
expect do
@@ -683,12 +683,12 @@ describe API::Pipelines do
end
describe 'POST /projects/:id/pipelines/:pipeline_id/cancel' do
- let!(:pipeline) do
+ let_it_be(:pipeline) do
create(:ci_empty_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch)
end
- let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
+ let_it_be(:build) { create(:ci_build, :running, pipeline: pipeline) }
context 'authorized user' do
it 'retries failed builds', :sidekiq_might_not_need_inline do
@@ -700,7 +700,7 @@ describe API::Pipelines do
end
context 'user without proper access rights' do
- let!(:reporter) { create(:user) }
+ let_it_be(:reporter) { create(:user) }
before do
project.add_reporter(reporter)
diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb
index 097171bbf8e..22189dc3299 100644
--- a/spec/requests/api/project_snippets_spec.rb
+++ b/spec/requests/api/project_snippets_spec.rb
@@ -216,12 +216,22 @@ describe API::ProjectSnippets do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'returns 400 for empty content field' do
+ it 'returns 400 if content is blank' do
params[:content] = ''
post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'content is empty'
+ end
+
+ it 'returns 400 if title is blank' do
+ params[:title] = ''
+
+ post api("/projects/#{project.id}/snippets/", admin), params: params
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'title is empty'
end
context 'when save fails because the repository could not be created' do
@@ -323,12 +333,19 @@ describe API::ProjectSnippets do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'returns 400 for empty content field' do
+ it 'returns 400 if content is blank' do
update_snippet(params: { content: '' })
expect(response).to have_gitlab_http_status(:bad_request)
end
+ it 'returns 400 if title is blank' do
+ update_snippet(params: { title: '' })
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'title is empty'
+ end
+
it_behaves_like 'update with repository actions' do
let(:snippet_without_repo) { create(:project_snippet, author: admin, project: project, visibility_level: visibility_level) }
end
diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb
index 074e662adcd..c12c95ae2e0 100644
--- a/spec/requests/api/snippets_spec.rb
+++ b/spec/requests/api/snippets_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe API::Snippets do
- let!(:user) { create(:user) }
+ let_it_be(:user) { create(:user) }
describe 'GET /snippets/' do
it 'returns snippets available' do
@@ -195,7 +195,7 @@ describe API::Snippets do
end
describe 'POST /snippets/' do
- let(:params) do
+ let(:base_params) do
{
title: 'Test Title',
file_name: 'test.rb',
@@ -204,12 +204,14 @@ describe API::Snippets do
visibility: 'public'
}
end
+ let(:params) { base_params.merge(extra_params) }
+ let(:extra_params) { {} }
+
+ subject { post api("/snippets/", user), params: params }
shared_examples 'snippet creation' do
let(:snippet) { Snippet.find(json_response["id"]) }
- subject { post api("/snippets/", user), params: params }
-
it 'creates a new snippet' do
expect do
subject
@@ -253,7 +255,7 @@ describe API::Snippets do
let(:user) { create(:user, :external) }
it 'does not create a new snippet' do
- post api("/snippets/", user), params: params
+ subject
expect(response).to have_gitlab_http_status(:forbidden)
end
@@ -262,17 +264,27 @@ describe API::Snippets do
it 'returns 400 for missing parameters' do
params.delete(:title)
- post api("/snippets/", user), params: params
+ subject
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'returns 400 for validation errors' do
+ it 'returns 400 if content is blank' do
+ params[:content] = ''
+
+ subject
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'content is empty'
+ end
+
+ it 'returns 400 if title is blank' do
params[:title] = ''
- post api("/snippets/", user), params: params
+ subject
expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'title is empty'
end
context 'when save fails because the repository could not be created' do
@@ -283,17 +295,13 @@ describe API::Snippets do
end
it 'returns 400' do
- post api("/snippets/", user), params: params
+ subject
expect(response).to have_gitlab_http_status(:bad_request)
end
end
context 'when the snippet is spam' do
- def create_snippet(snippet_params = {})
- post api('/snippets', user), params: params.merge(snippet_params)
- end
-
before do
allow_next_instance_of(Spam::AkismetService) do |instance|
allow(instance).to receive(:spam?).and_return(true)
@@ -301,23 +309,25 @@ describe API::Snippets do
end
context 'when the snippet is private' do
+ let(:extra_params) { { visibility: 'private' } }
+
it 'creates the snippet' do
- expect { create_snippet(visibility: 'private') }
- .to change { Snippet.count }.by(1)
+ expect { subject }.to change { Snippet.count }.by(1)
end
end
context 'when the snippet is public' do
+ let(:extra_params) { { visibility: 'public' } }
+
it 'rejects the shippet' do
- expect { create_snippet(visibility: 'public') }
- .not_to change { Snippet.count }
+ expect { subject }.not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" })
end
it 'creates a spam log' do
- expect { create_snippet(visibility: 'public') }
+ expect { subject }
.to log_spam(title: 'Test Title', user_id: user.id, noteable_type: 'PersonalSnippet')
end
end
@@ -325,8 +335,9 @@ describe API::Snippets do
end
describe 'PUT /snippets/:id' do
+ let_it_be(:other_user) { create(:user) }
+
let(:visibility_level) { Snippet::PUBLIC }
- let(:other_user) { create(:user) }
let(:snippet) do
create(:personal_snippet, :repository, author: user, visibility_level: visibility_level)
end
@@ -378,10 +389,18 @@ describe API::Snippets do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'returns 400 for validation errors' do
+ it 'returns 400 if content is blank' do
+ update_snippet(params: { content: '' })
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'content is empty'
+ end
+
+ it 'returns 400 if title is blank' do
update_snippet(params: { title: '' })
expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['error']).to eq 'title is empty'
end
it_behaves_like 'update with repository actions' do
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 864f6f77f39..4a0f0eea088 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -734,7 +734,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
describe "PUT /users/:id" do
- let!(:admin_user) { create(:admin) }
+ let_it_be(:admin_user) { create(:admin) }
it "returns 200 OK on success" do
put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
@@ -2405,8 +2405,8 @@ describe API::Users, :do_not_mock_admin_mode do
end
context "user activities", :clean_gitlab_redis_shared_state do
- let!(:old_active_user) { create(:user, last_activity_on: Time.utc(2000, 1, 1)) }
- let!(:newly_active_user) { create(:user, last_activity_on: 2.days.ago.midday) }
+ let_it_be(:old_active_user) { create(:user, last_activity_on: Time.utc(2000, 1, 1)) }
+ let_it_be(:newly_active_user) { create(:user, last_activity_on: 2.days.ago.midday) }
context 'last activity as normal user' do
it 'has no permission' do
diff --git a/spec/services/alert_management/create_alert_issue_service_spec.rb b/spec/services/alert_management/create_alert_issue_service_spec.rb
index 29b1ac8270d..62afe777165 100644
--- a/spec/services/alert_management/create_alert_issue_service_spec.rb
+++ b/spec/services/alert_management/create_alert_issue_service_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
before do
allow(user).to receive(:can?).and_call_original
allow(user).to receive(:can?)
- .with(:update_alert_management_alert, project)
+ .with(:create_issue, project)
.and_return(can_create)
end
@@ -62,6 +62,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
project.add_developer(user)
end
+ it 'checks permissions' do
+ execute
+ expect(user).to have_received(:can?).with(:create_issue, project)
+ end
+
context 'when the alert is prometheus alert' do
let(:alert) { prometheus_alert }
@@ -133,6 +138,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
context 'when a user is not allowed to create an issue' do
let(:can_create) { false }
+ it 'checks permissions' do
+ execute
+ expect(user).to have_received(:can?).with(:create_issue, project)
+ end
+
it 'responds with error' do
expect(execute).to be_error
expect(execute.message).to eq(_('You have no permissions'))
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb
index 2d225954a33..0aa603b24ae 100644
--- a/spec/services/ci/retry_build_service_spec.rb
+++ b/spec/services/ci/retry_build_service_spec.rb
@@ -22,9 +22,9 @@ describe Ci::RetryBuildService do
described_class.new(project, user)
end
- CLONE_ACCESSORS = described_class::CLONE_ACCESSORS
+ clone_accessors = described_class::CLONE_ACCESSORS
- REJECT_ACCESSORS =
+ reject_accessors =
%i[id status user token token_encrypted coverage trace runner
artifacts_expire_at
created_at updated_at started_at finished_at queued_at erased_by
@@ -40,7 +40,7 @@ describe Ci::RetryBuildService do
job_artifacts_network_referee job_artifacts_dotenv
job_artifacts_cobertura needs job_artifacts_accessibility].freeze
- IGNORE_ACCESSORS =
+ ignore_accessors =
%i[type lock_version target_url base_tags trace_sections
commit_id deployment erased_by_id project_id
runner_id tag_taggings taggings tags trigger_request_id
@@ -91,7 +91,7 @@ describe Ci::RetryBuildService do
end
end
- CLONE_ACCESSORS.each do |attribute|
+ clone_accessors.each do |attribute|
it "clones #{attribute} build attribute" do
expect(attribute).not_to be_in(forbidden_associations), "association #{attribute} must be `belongs_to`"
expect(build.send(attribute)).not_to be_nil
@@ -121,7 +121,7 @@ describe Ci::RetryBuildService do
end
describe 'reject accessors' do
- REJECT_ACCESSORS.each do |attribute|
+ reject_accessors.each do |attribute|
it "does not clone #{attribute} build attribute" do
expect(new_build.send(attribute)).not_to eq build.send(attribute)
end
@@ -129,8 +129,8 @@ describe Ci::RetryBuildService do
end
it 'has correct number of known attributes' do
- processed_accessors = CLONE_ACCESSORS + REJECT_ACCESSORS
- known_accessors = processed_accessors + IGNORE_ACCESSORS
+ processed_accessors = clone_accessors + reject_accessors
+ known_accessors = processed_accessors + ignore_accessors
# :tag_list is a special case, this accessor does not exist
# in reflected associations, comes from `act_as_taggable` and
diff --git a/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb b/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb
index c08b618fe6a..29ee897454a 100644
--- a/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb
+++ b/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Clusters::Applications::CheckUpgradeProgressService do
- RESCHEDULE_PHASES = ::Gitlab::Kubernetes::Pod::PHASES -
+ reschedule_phashes = ::Gitlab::Kubernetes::Pod::PHASES -
[::Gitlab::Kubernetes::Pod::SUCCEEDED, ::Gitlab::Kubernetes::Pod::FAILED, ::Gitlab].freeze
let(:application) { create(:clusters_applications_prometheus, :updating) }
@@ -89,6 +89,6 @@ describe Clusters::Applications::CheckUpgradeProgressService do
end
end
- RESCHEDULE_PHASES.each { |phase| it_behaves_like 'a not yet terminated upgrade', phase }
+ reschedule_phashes.each { |phase| it_behaves_like 'a not yet terminated upgrade', phase }
end
end
diff --git a/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb b/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb
index b386159541a..3d26ab2ede5 100644
--- a/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb
+++ b/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb
@@ -5,8 +5,6 @@ require 'spec_helper'
describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_store_caching do
include MetricsDashboardHelpers
- STAGES = ::Gitlab::Metrics::Dashboard::Stages
-
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:environment) { create(:environment, project: project) }
@@ -83,7 +81,7 @@ describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_stor
allow(::Gitlab::Metrics::Dashboard::Processor).to receive(:new).and_return(double(process: file_content_hash))
end
- it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH, [STAGES::CommonMetricsInserter, STAGES::CustomMetricsInserter, STAGES::Sorter]
+ it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH, [::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter, ::Gitlab::Metrics::Dashboard::Stages::CustomMetricsInserter, ::Gitlab::Metrics::Dashboard::Stages::Sorter]
context 'selected branch already exists' do
let(:branch) { 'existing_branch' }
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 38c1f97d3ea..80dfa20a2f1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -199,6 +199,10 @@ RSpec.configure do |config|
stub_feature_flags(vue_issuable_sidebar: false)
stub_feature_flags(vue_issuable_epic_sidebar: false)
+ allow(Feature).to receive(:enabled?)
+ .with(/\Apromo_\w+\z/, default_enabled: false)
+ .and_return(false)
+
# Stub these calls due to being expensive operations
# It can be reenabled for specific tests via:
#
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index 5be12d2cac1..130650b7e2e 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -59,7 +59,7 @@ module TestEnv
'merge-commit-analyze-side-branch' => '8a99451',
'merge-commit-analyze-after' => '646ece5',
'snippet/single-file' => '43e4080aaa14fc7d4b77ee1f5c9d067d5a7df10e',
- 'snippet/multiple-files' => 'b80faa8c5b2b62f6489a0d84755580e927e1189b',
+ 'snippet/multiple-files' => '40232f7eb98b3f221886432def6e8bab2432add9',
'snippet/rename-and-edit-file' => '220a1e4b4dff37feea0625a7947a4c60fbe78365',
'snippet/edit-file' => 'c2f074f4f26929c92795a75775af79a6ed6d8430',
'snippet/no-files' => '671aaa842a4875e5f30082d1ab6feda345fdb94d',
diff --git a/spec/uploaders/records_uploads_spec.rb b/spec/uploaders/records_uploads_spec.rb
index 71eff23c77c..1a3c416c74a 100644
--- a/spec/uploaders/records_uploads_spec.rb
+++ b/spec/uploaders/records_uploads_spec.rb
@@ -4,7 +4,9 @@ require 'spec_helper'
describe RecordsUploads do
let!(:uploader) do
- class RecordsUploadsExampleUploader < GitlabUploader
+ stub_const('RecordsUploadsExampleUploader', Class.new(GitlabUploader))
+
+ RecordsUploadsExampleUploader.class_eval do
include RecordsUploads::Concern
storage :file
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb
index 2fbaaf1131f..ae311a54cd1 100644
--- a/spec/workers/concerns/application_worker_spec.rb
+++ b/spec/workers/concerns/application_worker_spec.rb
@@ -21,6 +21,21 @@ describe ApplicationWorker do
end
end
+ describe '#logging_extras' do
+ it 'returns extra data to be logged that was set from #log_extra_metadata_on_done' do
+ instance.log_extra_metadata_on_done(:key1, "value1")
+ instance.log_extra_metadata_on_done(:key2, "value2")
+
+ expect(instance.logging_extras).to eq({ 'extra.gitlab_foo_bar_dummy_worker.key1' => "value1", 'extra.gitlab_foo_bar_dummy_worker.key2' => "value2" })
+ end
+
+ context 'when nothing is set' do
+ it 'returns {}' do
+ expect(instance.logging_extras).to eq({})
+ end
+ end
+ end
+
describe '#structured_payload' do
let(:payload) { {} }