Skip to content

Commit 4ec95e2

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent ec05f6e commit 4ec95e2

File tree

49 files changed

+580
-135
lines changed

Some content is hidden

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

49 files changed

+580
-135
lines changed

.rubocop_todo/gitlab/bounded_contexts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3176,7 +3176,6 @@ Gitlab/BoundedContexts:
31763176
- 'ee/app/services/ee/post_receive_service.rb'
31773177
- 'ee/app/services/ee/preview_markdown_service.rb'
31783178
- 'ee/app/services/ee/protected_branches/api_service.rb'
3179-
- 'ee/app/services/ee/protected_branches/base_service.rb'
31803179
- 'ee/app/services/ee/protected_branches/create_service.rb'
31813180
- 'ee/app/services/ee/protected_branches/destroy_service.rb'
31823181
- 'ee/app/services/ee/protected_branches/legacy_api_update_service.rb'

GITLAB_KAS_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7186455e61c1a6556cd6f0664a9c90c5da2e6bae
1+
da3a19a82c6c31f1dd1c29ce5ec48906d1594207

app/assets/javascripts/ml/experiment_tracking/components/performance_graph.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export default {
4242
return this.metricNames.map((metric) => {
4343
return {
4444
name: metric,
45-
data: this.candidates
45+
data: [...this.candidates]
46+
.sort((a, b) => new Date(a.created_at) - new Date(b.created_at))
4647
.filter((candidate) => candidate[metric] !== undefined && candidate[metric] !== null)
4748
.map((candidate, index) => ({
4849
value: [index + 1, parseFloat(candidate[metric])],

app/assets/javascripts/pages/projects/shared/web_ide_link/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default ({ el, router }) => {
4949
projectPath,
5050
cssClasses,
5151
...options,
52+
gitRef: ref,
5253
},
5354
});
5455
},

app/assets/javascripts/repository/components/header_area.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export default {
275275
:gitpod-url="gitpodUrl"
276276
:user-preferences-gitpod-path="userPreferencesGitpodPath"
277277
:user-profile-enable-gitpod-path="userProfileEnableGitpodPath"
278+
:git-ref="currentRef"
278279
disable-fork-modal
279280
v-on="$listeners"
280281
/>

app/assets/javascripts/work_items/components/work_item_description_template_listbox.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export default {
7474
},
7575
items() {
7676
return this.descriptionTemplates
77-
.filter(({ name }) => (this.searchTerm ? name.includes(this.searchTerm) : true))
77+
.filter(({ name }) =>
78+
this.searchTerm ? name.toLowerCase().includes(this.searchTerm.toLowerCase()) : true,
79+
)
7880
.reduce((groups, current) => {
7981
const idx = groups.findIndex((group) => group.text === current.category);
8082
if (idx > -1) {

app/controllers/graphql_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ def append_info_to_payload(payload)
297297

298298
# Merging to :metadata will ensure these are logged as top level keys
299299
payload[:metadata] ||= {}
300+
300301
payload[:metadata][:graphql] = logs
301302

303+
payload[:metadata][:referer] = request.headers['Referer'] if logs.any? { |log| log[:operation_name] == 'GLQL' }
304+
302305
payload[:exception_object] = @exception_object if @exception_object
303306
end
304307

app/helpers/projects_helper.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,19 @@ def visibility_level_content(project, css_class: nil, icon_css_class: nil)
674674
end
675675

676676
title = visibility_icon_description(project)
677-
container_class = ['has-tooltip', css_class].compact.join(' ')
677+
container_class = [
678+
'has-tooltip gl-border-0 gl-bg-transparent gl-p-0 gl-leading-0 gl-text-inherit',
679+
css_class
680+
].compact.join(' ')
678681
data = { container: 'body', placement: 'top' }
679682

680-
content_tag(:span, class: container_class, data: data, title: title) do
683+
content_tag(
684+
:button,
685+
class: container_class,
686+
data: data,
687+
title: title,
688+
type: 'button',
689+
aria: { label: title }) do
681690
visibility_level_icon(project.visibility_level, options: { class: icon_css_class })
682691
end
683692
end

app/models/ci/runner.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def self.runner_matchers
331331
end
332332
end
333333

334-
# TODO: Remove once https://gitlab.com/gitlab-org/gitlab/-/issues/504277 is closed.
334+
# TODO: Remove once https://gitlab.com/gitlab-org/gitlab/-/issues/516929 is closed.
335335
def self.sharded_table_proxy_model
336336
@sharded_table_proxy_class ||= Class.new(self) do
337337
self.table_name = :ci_runners_e59bb2812d
@@ -445,7 +445,7 @@ def has_tags?
445445
tag_list.any?
446446
end
447447

448-
# TODO: Remove once https://gitlab.com/gitlab-org/gitlab/-/issues/504277 is closed.
448+
# TODO: Remove once https://gitlab.com/gitlab-org/gitlab/-/issues/516929 is closed.
449449
def ensure_partitioned_runner_record_exists
450450
self.class.sharded_table_proxy_model.insert_all(
451451
[attributes.except('tag_list')], unique_by: [:id, :runner_type],
@@ -541,7 +541,7 @@ def ensure_manager(system_xid)
541541
RunnerManager.safe_find_or_create_by!(runner_id: id, system_xid: system_xid.to_s) do |m|
542542
# Avoid inserting partitioned runner managers that refer to a missing ci_runners partitioned record, since
543543
# the backfill is not yet finalized.
544-
ensure_partitioned_runner_record_exists
544+
ensure_partitioned_runner_record_exists if Feature.disabled?(:reject_orphaned_runners, Feature.current_request)
545545

546546
m.runner_type = runner_type
547547
m.sharding_key_id = sharding_key_id

app/models/virtual_registries/packages/maven/cache/entry.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Entry < ApplicationRecord
2828
enum :status, default: 0, processing: 1, pending_destruction: 2, error: 3
2929

3030
ignore_column :downloaded_at, remove_with: '17.9', remove_after: '2025-01-23'
31+
ignore_column :file_final_path, remove_with: '17.11', remove_after: '2025-03-23'
3132

3233
sha_attribute :file_sha1
3334
sha_attribute :file_md5
@@ -39,18 +40,19 @@ class Entry < ApplicationRecord
3940
:file_sha1,
4041
presence: true
4142
validates :upstream_etag, :content_type, length: { maximum: 255 }
42-
validates :relative_path, :object_storage_key, :file_final_path, length: { maximum: 1024 }
43+
validates :relative_path, :object_storage_key, length: { maximum: 1024 }
4344
validates :file_md5, length: { is: 32 }, allow_nil: true
4445
validates :file_sha1, length: { is: 40 }
4546
validates :relative_path,
4647
uniqueness: { scope: [:upstream_id, :status] },
4748
if: :default?
49+
validates :object_storage_key, uniqueness: { scope: :relative_path }
4850
validates :file, presence: true
4951

5052
mount_file_store_uploader ::VirtualRegistries::Cache::EntryUploader
5153

5254
before_validation :set_object_storage_key,
53-
if: -> { object_storage_key.blank? && relative_path && upstream && upstream.registry }
55+
if: -> { object_storage_key.blank? && upstream && upstream.registry }
5456
attr_readonly :object_storage_key
5557

5658
scope :search_by_relative_path, ->(query) do
@@ -106,18 +108,7 @@ def mark_as_pending_destruction
106108
private
107109

108110
def set_object_storage_key
109-
self.object_storage_key = Gitlab::HashedPath.new(
110-
'virtual_registries',
111-
'packages',
112-
'maven',
113-
upstream.registry.id,
114-
'upstream',
115-
upstream.id,
116-
'cache',
117-
'entry',
118-
OpenSSL::Digest::SHA256.hexdigest(relative_path),
119-
root_hash: upstream.registry.id
120-
).to_s
111+
self.object_storage_key = upstream.object_storage_key_for(registry_id: upstream.registry.id)
121112
end
122113
end
123114
end

app/models/virtual_registries/packages/maven/upstream.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ def default_cache_entries
5959
cache_entries.default
6060
end
6161

62+
def object_storage_key_for(registry_id:)
63+
hash = Digest::SHA2.hexdigest(SecureRandom.uuid)
64+
Gitlab::HashedPath.new(
65+
'virtual_registries',
66+
'packages',
67+
'maven',
68+
registry_id.to_s,
69+
'upstream',
70+
id.to_s,
71+
'cache',
72+
'entry',
73+
hash[0..1],
74+
hash[2..3],
75+
hash[4..],
76+
root_hash: registry_id
77+
).to_s
78+
end
79+
6280
private
6381

6482
def reset_credentials
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
module Authz
4+
module Applications
5+
class ResetSecretService
6+
attr_reader :application, :current_user
7+
8+
def initialize(application:, current_user:)
9+
@application = application
10+
@current_user = current_user
11+
end
12+
13+
def execute
14+
return error(message: "#{current_user.name} cannot reset secret") unless can_reset_secret?(current_user)
15+
16+
application.renew_secret
17+
18+
return ServiceResponse.success if application.save
19+
20+
error(message: "Couldn't save application")
21+
end
22+
23+
private
24+
25+
def error(message:)
26+
ServiceResponse.error(message: message)
27+
end
28+
29+
def can_reset_secret?(current_user)
30+
current_user.can_admin_all_resources?
31+
end
32+
end
33+
end
34+
end

app/services/ci/job_artifacts/create_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def authorize(artifact_type:, filesize: nil)
2727
has_length: false,
2828
maximum_size: max_size(artifact_type),
2929
use_final_store_path: true,
30-
final_store_path_root_id: project.id
30+
final_store_path_config: { root_hash: project.id }
3131
)
3232

3333
if lsif?(artifact_type)

app/services/protected_branches/create_service.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,29 @@ def save_protected_branch
2222
protected_branch.save.tap do
2323
# Refresh all_protected_branches association as it is not automatically updated
2424
project_or_group.all_protected_branches.reset if project_or_group.is_a?(Project)
25+
26+
publish_created_event
2527
end
2628
end
2729

30+
def publish_created_event
31+
return unless protected_branch.id
32+
33+
parent_type = if project_or_group.is_a?(Project)
34+
::Repositories::ProtectedBranchCreatedEvent::PARENT_TYPES[:project]
35+
else
36+
::Repositories::ProtectedBranchCreatedEvent::PARENT_TYPES[:group]
37+
end
38+
39+
::Gitlab::EventStore.publish(
40+
::Repositories::ProtectedBranchCreatedEvent.new(data: {
41+
protected_branch_id: protected_branch.id,
42+
parent_id: project_or_group.id,
43+
parent_type: parent_type
44+
})
45+
)
46+
end
47+
2848
def protected_branch
2949
@protected_branch ||= project_or_group.protected_branches.new(params)
3050
end

app/services/protected_branches/destroy_service.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,24 @@ def execute(protected_branch)
77

88
protected_branch.destroy.tap do
99
refresh_cache
10-
after_execute
10+
publish_deleted_event
1111
end
1212
end
13+
14+
def publish_deleted_event
15+
parent_type = if project_or_group.is_a?(Project)
16+
::Repositories::ProtectedBranchDestroyedEvent::PARENT_TYPES[:project]
17+
else
18+
::Repositories::ProtectedBranchDestroyedEvent::PARENT_TYPES[:group]
19+
end
20+
21+
::Gitlab::EventStore.publish(
22+
::Repositories::ProtectedBranchDestroyedEvent.new(data: {
23+
parent_id: project_or_group.id,
24+
parent_type: parent_type
25+
})
26+
)
27+
end
1328
end
1429
end
1530

app/uploaders/object_storage.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def generate_remote_id
177177
[CarrierWave.generate_cache_id, SecureRandom.hex].join('-')
178178
end
179179

180-
def generate_final_store_path(root_id:)
180+
def generate_final_store_path(root_hash:)
181181
hash = Digest::SHA2.hexdigest(SecureRandom.uuid)
182182

183183
# We prefix '@final' to prevent clashes and make the files easily recognizable
@@ -186,21 +186,26 @@ def generate_final_store_path(root_id:)
186186

187187
# We generate a hashed path of the root ID (e.g. Project ID) to distribute directories instead of
188188
# filling up one root directory with a bunch of files.
189-
Gitlab::HashedPath.new(sub_path, root_hash: root_id).to_s
189+
Gitlab::HashedPath.new(sub_path, root_hash: root_hash).to_s
190190
end
191191

192+
# final_store_path_config is only used if use_final_store_path is set to true
193+
# Two keys are available:
194+
# - :root_hash. The root hash used in Gitlab::HashedPath for the path generation.
195+
# - :override_path. If set, the path generation is skipped and this value is used instead.
196+
# Make sure that this value is unique for each upload.
192197
def workhorse_authorize(
193198
has_length:,
194199
maximum_size: nil,
195200
use_final_store_path: false,
196-
final_store_path_root_id: nil)
201+
final_store_path_config: {})
197202
{}.tap do |hash|
198203
if self.direct_upload_to_object_store?
199204
hash[:RemoteObject] = workhorse_remote_upload_options(
200205
has_length: has_length,
201206
maximum_size: maximum_size,
202207
use_final_store_path: use_final_store_path,
203-
final_store_path_root_id: final_store_path_root_id
208+
final_store_path_config: final_store_path_config
204209
)
205210
else
206211
hash[:TempPath] = workhorse_local_upload_path
@@ -231,13 +236,18 @@ def workhorse_remote_upload_options(
231236
has_length:,
232237
maximum_size: nil,
233238
use_final_store_path: false,
234-
final_store_path_root_id: nil)
239+
final_store_path_config: {})
235240
return unless direct_upload_to_object_store?
236241

237242
if use_final_store_path
238-
raise MissingFinalStorePathRootId unless final_store_path_root_id.present?
243+
id = if final_store_path_config[:override_path].present?
244+
final_store_path_config[:override_path]
245+
else
246+
raise MissingFinalStorePathRootId unless final_store_path_config[:root_hash].present?
247+
248+
generate_final_store_path(root_hash: final_store_path_config[:root_hash])
249+
end
239250

240-
id = generate_final_store_path(root_id: final_store_path_root_id)
241251
upload_path = with_bucket_prefix(id)
242252
prepare_pending_direct_upload(id)
243253
else

app/uploaders/virtual_registries/cache/entry_uploader.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def sync_model_object_store?
2828
true
2929
end
3030

31+
override :direct_upload_final_path_attribute_name
32+
def direct_upload_final_path_attribute_name
33+
:object_storage_key
34+
end
35+
3136
private
3237

3338
def set_content_type(file)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: reject_orphaned_runners
3+
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/516862
4+
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/180163
5+
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/516929
6+
milestone: '17.9'
7+
group: group::runner
8+
type: gitlab_com_derisk
9+
default_enabled: false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
class AddObjectStorageKeyUniqueToVRegsPackagesMavenCacheEntries < Gitlab::Database::Migration[2.2]
4+
include Gitlab::Database::PartitioningMigrationHelpers
5+
6+
milestone '17.9'
7+
8+
disable_ddl_transaction!
9+
10+
TABLE_NAME = :virtual_registries_packages_maven_cache_entries
11+
COLUMNS = [:relative_path, :object_storage_key]
12+
INDEX_NAME = :idx_vregs_pkgs_mvn_cache_entries_on_uniq_object_storage_key
13+
14+
def up
15+
truncate_tables!(TABLE_NAME.to_s)
16+
add_concurrent_partitioned_index TABLE_NAME, COLUMNS, unique: true, name: INDEX_NAME
17+
end
18+
19+
def down
20+
remove_concurrent_partitioned_index_by_name TABLE_NAME, INDEX_NAME
21+
end
22+
end

db/schema_migrations/20250128153614

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d43f2fa892bb1a4b268197cd6c83b6f1437c80677fae1caadc61b52caf45f2e5

0 commit comments

Comments
 (0)