Skip to content

Commit 8ebd99a

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent c283bdb commit 8ebd99a

File tree

65 files changed

+404
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+404
-295
lines changed

.gitlab/ci/rails/shared.gitlab-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ include:
6767
RECORD_DEPRECATIONS: "true"
6868
GEO_SECONDARY_PROXY: 0
6969
SUCCESSFULLY_RETRIED_TEST_EXIT_CODE: 137
70+
EVENT_PROF: "sql.active_record"
7071
needs:
7172
- job: "setup-test-env"
7273
- job: "retrieve-tests-metadata"

app/controllers/oauth/authorized_applications_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def destroy
1919
Doorkeeper::Application.revoke_tokens_and_grants_for(params[:id], current_resource_owner)
2020
end
2121

22-
redirect_to applications_profile_url,
22+
redirect_to user_settings_applications_url,
2323
status: :found,
2424
notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
2525
end

app/controllers/projects/deploy_keys_controller.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def enabled_keys
2626
respond_to do |format|
2727
format.json do
2828
enabled_keys = find_keys(filter: :enabled_keys)
29-
render json: serialize(enabled_keys)
29+
render json: { keys: serialize(enabled_keys) }
3030
end
3131
end
3232
end
@@ -35,7 +35,7 @@ def available_project_keys
3535
respond_to do |format|
3636
format.json do
3737
available_project_keys = find_keys(filter: :available_project_keys)
38-
render json: serialize(available_project_keys)
38+
render json: { keys: serialize(available_project_keys) }
3939
end
4040
end
4141
end
@@ -45,7 +45,7 @@ def available_public_keys
4545
format.json do
4646
available_public_keys = find_keys(filter: :available_public_keys)
4747

48-
render json: serialize(available_public_keys)
48+
render json: { keys: serialize(available_public_keys) }
4949
end
5050
end
5151
end

app/graphql/mutations/container_registry/protection/rule/create.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class Create < ::Mutations::BaseMutation
1818
required: true,
1919
description: 'Full path of the project where a protection rule is located.'
2020

21-
argument :container_path_pattern,
21+
argument :repository_path_pattern,
2222
GraphQL::Types::String,
2323
required: true,
2424
description:
25-
'ContainerRegistryname protected by the protection rule. For example `@my-scope/my-container-*`. ' \
26-
'Wildcard character `*` allowed.'
25+
'Container repository path pattern protected by the protection rule. ' \
26+
'For example `my-project/my-container-*`. Wildcard character `*` allowed.'
2727

2828
argument :push_protected_up_to_access_level,
2929
Types::ContainerRegistry::Protection::RuleAccessLevelEnum,

app/graphql/types/container_registry/protection/rule_type.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class RuleType < ::Types::BaseObject
1515
null: false,
1616
description: 'ID of the container registry protection rule.'
1717

18-
field :container_path_pattern,
18+
field :repository_path_pattern,
1919
GraphQL::Types::String,
2020
null: false,
2121
description:
2222
'Container repository path pattern protected by the protection rule. ' \
23-
'For example `@my-scope/my-container-*`. Wildcard character `*` allowed.'
23+
'For example `my-project/my-container-*`. Wildcard character `*` allowed.'
2424

2525
field :push_protected_up_to_access_level,
2626
Types::ContainerRegistry::Protection::RuleAccessLevelEnum,

app/models/bulk_import.rb

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class BulkImport < ApplicationRecord
1717
enum source_type: { gitlab: 0 }
1818

1919
scope :stale, -> { where('updated_at < ?', 24.hours.ago).where(status: [0, 1]) }
20+
scope :order_by_updated_at_and_id, ->(direction) { order(updated_at: direction, id: :asc) }
2021
scope :order_by_created_at, ->(direction) { order(created_at: direction) }
2122

2223
state_machine :status, initial: :created do

app/models/bulk_imports/entity.rb

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class BulkImports::Entity < ApplicationRecord
5757
scope :stale, -> { where('updated_at < ?', 24.hours.ago).where(status: [0, 1]) }
5858
scope :by_bulk_import_id, ->(bulk_import_id) { where(bulk_import_id: bulk_import_id) }
5959
scope :order_by_created_at, ->(direction) { order(created_at: direction) }
60+
scope :order_by_updated_at_and_id, ->(direction) { order(updated_at: direction, id: :asc) }
61+
scope :with_trackers, -> { includes(:trackers) }
6062

6163
alias_attribute :destination_slug, :destination_name
6264

app/models/container_registry/protection/rule.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
module ContainerRegistry
44
module Protection
55
class Rule < ApplicationRecord
6+
include IgnorableColumns
7+
8+
ignore_column :container_path_pattern, remove_with: '16.8', remove_after: '2023-12-22'
9+
610
enum delete_protected_up_to_access_level:
711
Gitlab::Access.sym_options_with_owner.slice(:maintainer, :owner, :developer),
812
_prefix: :delete_protected_up_to
@@ -12,7 +16,7 @@ class Rule < ApplicationRecord
1216

1317
belongs_to :project, inverse_of: :container_registry_protection_rules
1418

15-
validates :container_path_pattern, presence: true, uniqueness: { scope: :project_id }, length: { maximum: 255 }
19+
validates :repository_path_pattern, presence: true, uniqueness: { scope: :project_id }, length: { maximum: 255 }
1620
validates :delete_protected_up_to_access_level, presence: true
1721
validates :push_protected_up_to_access_level, presence: true
1822
end

app/serializers/deploy_keys/basic_deploy_key_entity.rb

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module DeployKeys
44
class BasicDeployKeyEntity < Grape::Entity
5+
include RequestAwareEntity
6+
57
expose :id
68
expose :user_id
79
expose :title
@@ -14,6 +16,17 @@ class BasicDeployKeyEntity < Grape::Entity
1416
expose :updated_at
1517
expose :can_edit
1618
expose :user, as: :owner, using: ::API::Entities::UserBasic, if: -> (_, opts) { can_read_owner?(opts) }
19+
expose :edit_path, if: -> (_, opts) { opts[:project] } do |deploy_key|
20+
edit_project_deploy_key_path(options[:project], deploy_key)
21+
end
22+
23+
expose :enable_path, if: -> (_, opts) { opts[:project] } do |deploy_key|
24+
enable_project_deploy_key_path(options[:project], deploy_key)
25+
end
26+
27+
expose :disable_path, if: -> (_, opts) { opts[:project] } do |deploy_key|
28+
disable_project_deploy_key_path(options[:project], deploy_key)
29+
end
1730

1831
private
1932

app/services/container_registry/protection/create_rule_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ContainerRegistry
44
module Protection
55
class CreateRuleService < BaseService
66
ALLOWED_ATTRIBUTES = %i[
7-
container_path_pattern
7+
repository_path_pattern
88
push_protected_up_to_access_level
99
delete_protected_up_to_access_level
1010
].freeze

app/services/import/github_service.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def execute(access_params, provider)
1616
track_access_level('github')
1717

1818
if project.persisted?
19-
store_import_settings(project, access_params)
19+
store_import_settings(project)
2020
success(project)
2121
elsif project.errors[:import_source_disabled].present?
2222
error(project.errors[:import_source_disabled], :forbidden)
@@ -134,13 +134,12 @@ def log_and_return_error(message, translated_message, http_status)
134134
error(translated_message, http_status)
135135
end
136136

137-
def store_import_settings(project, access_params)
137+
def store_import_settings(project)
138138
Gitlab::GithubImport::Settings
139139
.new(project)
140140
.write(
141141
timeout_strategy: params[:timeout_strategy] || ProjectImportData::PESSIMISTIC_TIMEOUT,
142-
optional_stages: params[:optional_stages],
143-
additional_access_tokens: access_params[:additional_access_tokens]
142+
optional_stages: params[:optional_stages]
144143
)
145144
end
146145
end

app/workers/bulk_imports/stuck_import_worker.rb

+24-11
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@ class StuckImportWorker
1212

1313
feature_category :importers
1414

15+
# Using Keyset pagination for scopes that involve timestamp indexes
1516
def perform
16-
BulkImport.stale.find_each do |import|
17-
logger.error(message: 'BulkImport stale', bulk_import_id: import.id)
18-
import.cleanup_stale
17+
Gitlab::Pagination::Keyset::Iterator.new(scope: bulk_import_scope).each_batch do |imports|
18+
imports.each do |import|
19+
logger.error(message: 'BulkImport stale', bulk_import_id: import.id)
20+
import.cleanup_stale
21+
end
1922
end
2023

21-
BulkImports::Entity.includes(:trackers).stale.find_each do |entity| # rubocop: disable CodeReuse/ActiveRecord
22-
ApplicationRecord.transaction do
23-
logger.with_entity(entity).error(
24-
message: 'BulkImports::Entity stale'
25-
)
24+
Gitlab::Pagination::Keyset::Iterator.new(scope: entity_scope).each_batch do |entities|
25+
entities.each do |entity|
26+
ApplicationRecord.transaction do
27+
logger.with_entity(entity).error(
28+
message: 'BulkImports::Entity stale'
29+
)
2630

27-
entity.cleanup_stale
31+
entity.cleanup_stale
2832

29-
entity.trackers.find_each do |tracker|
30-
tracker.cleanup_stale
33+
entity.trackers.find_each do |tracker|
34+
tracker.cleanup_stale
35+
end
3136
end
3237
end
3338
end
@@ -36,5 +41,13 @@ def perform
3641
def logger
3742
@logger ||= Logger.build
3843
end
44+
45+
def bulk_import_scope
46+
BulkImport.stale.order_by_updated_at_and_id(:asc)
47+
end
48+
49+
def entity_scope
50+
BulkImports::Entity.with_trackers.stale.order_by_updated_at_and_id(:asc)
51+
end
3952
end
4053
end

app/workers/concerns/gitlab/github_import/object_importer.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ def import(project, client, hash)
5757
end
5858

5959
info(project.id, message: 'importer finished')
60-
rescue NoMethodError => e
61-
# This exception will be more useful in development when a new
62-
# Representation is created but the developer forgot to add a
63-
# `#github_identifiers` method.
64-
track_and_raise_exception(project, e, fail_import: true)
65-
rescue ActiveRecord::RecordInvalid, NotRetriableError => e
60+
rescue ActiveRecord::RecordInvalid, NotRetriableError, NoMethodError => e
6661
# We do not raise exception to prevent job retry
6762
track_exception(project, e)
6863
rescue StandardError => e

config/feature_flags/development/custom_roles_in_members_page.yml

-8
This file was deleted.

config/routes/profile.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
resource :profile, only: [:show, :update] do
77
member do
88
get :audit_log, to: redirect('-/user_settings/authentication_log')
9-
get :applications, to: 'oauth/applications#index'
9+
get :applications, to: redirect('-/user_settings/applications')
1010

1111
put :reset_incoming_email_token
1212
put :reset_feed_token

config/routes/user_settings.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace :user_settings do
44
scope module: 'user_settings' do
55
get :authentication_log
6+
get :applications, to: '/oauth/applications#index'
67
end
78
resources :active_sessions, only: [:index, :destroy]
89
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
class RenameContainerRegistryProtectionRulesContainerPathPattern < Gitlab::Database::Migration[2.2]
4+
milestone '16.7'
5+
6+
disable_ddl_transaction!
7+
8+
def up
9+
rename_column_concurrently :container_registry_protection_rules, :container_path_pattern, :repository_path_pattern
10+
end
11+
12+
def down
13+
undo_rename_column_concurrently :container_registry_protection_rules, :container_path_pattern,
14+
:repository_path_pattern
15+
end
16+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class RenameIndexIContainerProtectionUniqueProjectIdContainerPathPattern < Gitlab::Database::Migration[2.2]
4+
milestone '16.7'
5+
6+
disable_ddl_transaction!
7+
8+
def up
9+
rename_index :container_registry_protection_rules, :idx_copy_d01a85dee8,
10+
:i_container_protection_unique_project_repository_path_pattern
11+
end
12+
13+
def down
14+
rename_index :container_registry_protection_rules, :i_container_protection_unique_project_repository_path_pattern,
15+
:idx_copy_d01a85dee8
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
class CleanupContainerRegistryProtectionRulesContainerPathPatternAtRename < Gitlab::Database::Migration[2.2]
4+
milestone '16.7'
5+
6+
disable_ddl_transaction!
7+
8+
def up
9+
cleanup_concurrent_column_rename :container_registry_protection_rules, :container_path_pattern,
10+
:repository_path_pattern
11+
end
12+
13+
def down
14+
undo_cleanup_concurrent_column_rename :container_registry_protection_rules, :container_path_pattern,
15+
:repository_path_pattern
16+
17+
# Restoring the old index name `:i_container_protection_unique_project_id_container_path_pattern`
18+
# that was changed in the following migrations:
19+
# - `db/migrate/20231126200903_rename_container_registry_protection_rules_container_path_pattern.rb`
20+
# - `db/migrate/20231126200904_rename_index_i_container_protection_unique_project_id_container_path_pattern.rb`
21+
if index_exists?(:container_registry_protection_rules, [:project_id, :container_path_pattern],
22+
name: :i_container_protection_unique_project_container_path_pattern)
23+
rename_index :container_registry_protection_rules, :i_container_protection_unique_project_container_path_pattern,
24+
:i_container_protection_unique_project_id_container_path_pattern
25+
end
26+
end
27+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# frozen_string_literal: true
2+
3+
class CleanupCiStagesPipelineIdBigintForSelfHost < Gitlab::Database::Migration[2.2]
4+
disable_ddl_transaction!
5+
milestone "16.7"
6+
7+
TABLE = :ci_stages
8+
REFERENCING_TABLE = :ci_pipelines
9+
COLUMN = :pipeline_id
10+
OLD_COLUMN = :pipeline_id_convert_to_bigint
11+
INDEXES = {
12+
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [
13+
[:pipeline_id_convert_to_bigint, :name], { unique: true }
14+
],
15+
'index_ci_stages_on_pipeline_id_convert_to_bigint' => [
16+
[:pipeline_id_convert_to_bigint], {}
17+
],
18+
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [
19+
[:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' }
20+
],
21+
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [
22+
[:pipeline_id_convert_to_bigint, :position], {}
23+
]
24+
}
25+
26+
def up
27+
return unless column_exists?(TABLE, OLD_COLUMN)
28+
29+
with_lock_retries(raise_on_exhaustion: true) do
30+
lock_tables(REFERENCING_TABLE, TABLE)
31+
cleanup_conversion_of_integer_to_bigint(TABLE, [COLUMN])
32+
end
33+
end
34+
35+
def down
36+
return if column_exists?(TABLE, OLD_COLUMN)
37+
# See db/post_migrate/20231120070345_cleanup_ci_stages_pipeline_id_bigint.rb
38+
# Both Gitlab.com and dev/test envinronments will be handled in that migration.
39+
return if Gitlab.com_except_jh? || Gitlab.dev_or_test_env?
40+
41+
restore_conversion_of_integer_to_bigint(TABLE, [COLUMN])
42+
43+
INDEXES.each do |index_name, (columns, options)|
44+
add_concurrent_index(TABLE, columns, name: index_name, **options)
45+
end
46+
47+
add_concurrent_foreign_key(
48+
TABLE, REFERENCING_TABLE,
49+
column: OLD_COLUMN,
50+
on_delete: :cascade, validate: true, reverse_lock_order: true
51+
)
52+
end
53+
end

db/schema_migrations/20231126200903

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
89c33f31982aa26a63cdbd1fd35d51c984006d6ae66dc3cac8e88f3a8fadf461

db/schema_migrations/20231126200904

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9b1a9d983f5feebe9a7a64a653ff300dbb7b5d12520d751d875527755ca15c61

db/schema_migrations/20231126220000

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f841d351a89d3ed9b2fea8d386b528aff5f1a267c214f6f0a150281377522d44

db/schema_migrations/20231207054819

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b59e995833c187b21e561f3be24d53e1e6e56cee1f7a5933546b55f8a3a731c8

0 commit comments

Comments
 (0)