Skip to content

Commit 20d3e87

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 6c20a11 commit 20d3e87

File tree

43 files changed

+532
-159
lines changed

Some content is hidden

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

43 files changed

+532
-159
lines changed

.gitlab/ci/reports.gitlab-ci.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,23 @@ pajamas_adoption:
143143
extends:
144144
- .default-retry
145145
- .reports:rules:pajamas_adoption
146-
allow_failure: true
146+
allow_failure:
147+
# The scanner exits with status:
148+
# - 0 when no errors occur, and no blocking findings are found;
149+
# - 1 when unexpected errors occur;
150+
# - 2 when blocking findings are found.
151+
# We only want to block the merge request in this last case.
152+
exit_codes: 1
147153
image: ${REGISTRY_HOST}/${REGISTRY_GROUP}/frontend/pajamas-adoption-scanner:latest
148154
stage: lint
149155
needs: []
156+
variables:
157+
FF_USE_NEW_BASH_EVAL_STRATEGY: 'true'
150158
script:
151-
- EE_APP=$(test -d ee/app/ && echo 'ee/app/' || true)
152-
- scan_gitlab_code_quality app/ $EE_APP
159+
- scan_gitlab_code_quality {,ee/}app/
153160
artifacts:
154161
name: pajamas-adoption
162+
when: always
155163
paths:
156164
- gl-code-quality-report.json
157165
- pas-findings.json

.gitlab/ci/rules.gitlab-ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2727,7 +2727,8 @@
27272727
- <<: *if-merge-request
27282728
changes:
27292729
- '{,ee/}app/**/*.{js,vue,rb,haml}'
2730-
- <<: *if-default-refs
2730+
- <<: *if-default-branch-refs
2731+
allow_failure: true
27312732

27322733
################
27332734
# Review rules #

.rubocop_todo/layout/empty_line_after_magic_comment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ Layout/EmptyLineAfterMagicComment:
126126
- 'config/routes/merge_requests.rb'
127127
- 'danger/ce_ee_vue_templates/Dangerfile'
128128
- 'danger/feature_flag/Dangerfile'
129-
- 'danger/pajamas/Dangerfile'
130129
- 'ee/app/controllers/concerns/epics_actions.rb'
131130
- 'ee/app/controllers/concerns/saml_authorization.rb'
132131
- 'ee/app/controllers/ee/projects/analytics/cycle_analytics/stages_controller.rb'

.rubocop_todo/layout/line_length.yml

-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ Layout/LineLength:
668668
- 'danger/ci_config/Dangerfile'
669669
- 'danger/documentation/Dangerfile'
670670
- 'danger/feature_flag/Dangerfile'
671-
- 'danger/pajamas/Dangerfile'
672671
- 'danger/roulette/Dangerfile'
673672
- 'danger/vue_shared_documentation/Dangerfile'
674673
- 'ee/app/controllers/admin/elasticsearch_controller.rb'

.rubocop_todo/lint/missing_cop_enable_directive.yml

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Lint/MissingCopEnableDirective:
5959
- 'app/services/projects/container_repository/third_party/delete_tags_service.rb'
6060
- 'app/services/search/global_service.rb'
6161
- 'danger/feature_flag/Dangerfile'
62-
- 'danger/pajamas/Dangerfile'
6362
- 'ee/app/controllers/ee/admin/dashboard_controller.rb'
6463
- 'ee/app/controllers/ee/admin/groups_controller.rb'
6564
- 'ee/app/controllers/ee/admin/users_controller.rb'

app/assets/javascripts/emoji/components/picker.vue

+9-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default {
145145
<gl-button
146146
v-gl-tooltip
147147
:title="$options.i18n.addReaction"
148-
:class="toggleClass"
148+
:class="[toggleClass, { 'is-active': isVisible }]"
149149
class="gl-relative gl-h-full"
150150
data-testid="add-reaction-button"
151151
>
@@ -154,10 +154,16 @@ export default {
154154
<gl-icon class="award-control-icon-neutral gl-button-icon" name="slight-smile" />
155155
</span>
156156
<span class="reaction-control-icon reaction-control-icon-positive">
157-
<gl-icon class="award-control-icon-positive gl-button-icon" name="smiley" />
157+
<gl-icon
158+
class="award-control-icon-positive gl-button-icon gl-left-3!"
159+
name="smiley"
160+
/>
158161
</span>
159162
<span class="reaction-control-icon reaction-control-icon-super-positive">
160-
<gl-icon class="award-control-icon-super-positive gl-button-icon" name="smile" />
163+
<gl-icon
164+
class="award-control-icon-super-positive gl-button-icon gl-left-3!"
165+
name="smile"
166+
/>
161167
</span>
162168
</slot>
163169
</gl-button>

app/assets/javascripts/packages_and_registries/settings/project/components/packages_protection_rules.vue

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export default {
135135
:fields="$options.fields"
136136
show-empty
137137
stacked="md"
138+
class="mb-3"
139+
:aria-label="$options.i18n.settingBlockTitle"
138140
:busy="isLoadingPackageProtectionRules"
139141
>
140142
<template #table-busy>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,21 @@ export default {
112112
</div>
113113
<div
114114
class="committer gl-flex-basis-full"
115-
:class="truncateAuthorName ? 'gl-display-inline-flex' : ''"
115+
:class="{ 'gl-display-inline-flex': truncateAuthorName }"
116116
data-testid="committer"
117117
>
118118
<gl-link
119119
v-if="commit.author"
120120
:href="commit.author.webPath"
121121
class="commit-author-link js-user-link"
122-
:class="truncateAuthorName ? 'gl-display-inline-block gl-text-truncate' : ''"
122+
:class="{ 'gl-display-inline-block gl-text-truncate': truncateAuthorName }"
123123
>
124124
{{ commit.author.name }}</gl-link
125125
>
126126
<template v-else>
127127
{{ commit.authorName }}
128128
</template>
129-
{{ $options.i18n.authored }}&nbsp;
129+
{{ $options.i18n.authored }}
130130
<timeago-tooltip :time="commit.authoredDate" tooltip-placement="bottom" />
131131
</div>
132132
<pre

app/assets/stylesheets/framework/files.scss

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ span.idiff {
413413
}
414414

415415
.version-link {
416+
display: inline-block;
416417
align-self: center;
417418
margin-top: $gl-spacing-scale-2;
418419
width: $gl-spacing-scale-5;

app/assets/stylesheets/pages/commits.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@
137137
color: $gl-text-color;
138138
}
139139

140+
&.gl-display-inline-flex {
141+
gap: 0.5ch;
142+
}
143+
140144
.commit-author-link.gl-text-truncate {
141-
max-width: 20ch;
145+
max-width: 19ch;
142146
}
143147
}
144148
}

app/models/namespaces/descendants.rb

+40
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,45 @@ def self.expire_for(namespace_ids)
2626

2727
connection.execute(sanitize_sql_array([sql, namespace_ids, namespace_ids, Time.current]))
2828
end
29+
30+
def self.load_outdated_batch(batch_size)
31+
where
32+
.not(outdated_at: nil)
33+
.limit(batch_size)
34+
.lock('FOR UPDATE SKIP LOCKED')
35+
.pluck_primary_key
36+
end
37+
38+
def self.upsert_with_consistent_data(namespace:, self_and_descendant_group_ids:, all_project_ids:)
39+
query = <<~SQL
40+
INSERT INTO namespace_descendants
41+
(namespace_id, traversal_ids, self_and_descendant_group_ids, all_project_ids, outdated_at, calculated_at)
42+
VALUES
43+
(
44+
?,
45+
ARRAY[?]::bigint[],
46+
ARRAY_REMOVE(ARRAY[?]::bigint[], NULL),
47+
ARRAY_REMOVE(ARRAY[?]::bigint[], NULL),
48+
NULL,
49+
?
50+
)
51+
ON CONFLICT(namespace_id)
52+
DO UPDATE SET
53+
traversal_ids = EXCLUDED.traversal_ids,
54+
self_and_descendant_group_ids = EXCLUDED.self_and_descendant_group_ids,
55+
all_project_ids = EXCLUDED.all_project_ids,
56+
outdated_at = EXCLUDED.outdated_at,
57+
calculated_at = EXCLUDED.calculated_at
58+
SQL
59+
60+
connection.execute(sanitize_sql_array([
61+
query,
62+
namespace.id,
63+
namespace.traversal_ids,
64+
self_and_descendant_group_ids,
65+
all_project_ids,
66+
Time.current
67+
]))
68+
end
2969
end
3070
end

app/models/project.rb

+11-2
Original file line numberDiff line numberDiff line change
@@ -1942,8 +1942,17 @@ def check_repository_path_availability
19421942
end
19431943

19441944
def track_project_repository
1945-
repository = project_repository || build_project_repository
1946-
repository.update!(shard_name: repository_storage, disk_path: disk_path)
1945+
(project_repository || build_project_repository).tap do |proj_repo|
1946+
attributes = { shard_name: repository_storage, disk_path: disk_path }
1947+
1948+
if Feature.enabled?(:store_object_format, namespace, type: :gitlab_com_derisk)
1949+
object_format = repository.object_format
1950+
1951+
attributes[:object_format] = object_format if object_format.present?
1952+
end
1953+
1954+
proj_repo.update!(**attributes)
1955+
end
19471956

19481957
cleanup
19491958
end

app/models/repository.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,6 @@ def get_file_attributes(revision, paths, attributes)
12811281
end
12821282

12831283
def object_format
1284-
return unless exists?
1285-
12861284
cache_key = "object_format:#{full_path}"
12871285

12881286
request_store_cache.fetch(cache_key) do
@@ -1293,6 +1291,8 @@ def object_format
12931291
FORMAT_SHA256
12941292
end
12951293
end
1294+
rescue Gitlab::Git::Repository::NoRepository
1295+
nil
12961296
end
12971297

12981298
def blank_ref

app/models/work_items/dates_source.rb

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

33
module WorkItems
44
class DatesSource < ApplicationRecord
5+
include FromUnion
6+
57
self.table_name = 'work_item_dates_sources'
68

79
# namespace is required as the sharding key
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# frozen_string_literal: true
2+
3+
module Namespaces
4+
class UpdateDenormalizedDescendantsService
5+
include Gitlab::Utils::StrongMemoize
6+
7+
NAMESPACE_TYPE_MAPPING = {
8+
'Project' => :all_project_ids,
9+
'Group' => :self_and_descendant_group_ids
10+
}.freeze
11+
12+
def initialize(namespace_id:)
13+
@namespace_id = namespace_id
14+
end
15+
16+
def execute
17+
Namespaces::Descendants.transaction do
18+
namespace = Namespace.primary_key_in(namespace_id).lock.first # rubocop: disable CodeReuse/ActiveRecord -- this is a special service for updating records
19+
# If there is another process updating the hierarchy, this query will return nil and we just
20+
# stop the processing.
21+
descendants = Namespaces::Descendants.primary_key_in(namespace_id).lock('FOR UPDATE SKIP LOCKED').first # rubocop: disable CodeReuse/ActiveRecord -- this is a special service for updating records
22+
next unless descendants
23+
24+
if namespace
25+
update_namespace_descendants(namespace)
26+
else
27+
descendants.destroy
28+
end
29+
end
30+
end
31+
32+
private
33+
34+
attr_reader :namespace_id
35+
36+
def update_namespace_descendants(namespace)
37+
ids = collect_namespace_ids
38+
39+
Namespaces::Descendants.upsert_with_consistent_data(
40+
namespace: namespace,
41+
self_and_descendant_group_ids: ids[:self_and_descendant_group_ids].sort,
42+
all_project_ids: Project.where(project_namespace_id: ids[:all_project_ids]).order(:id).pluck_primary_key # rubocop: disable CodeReuse/ActiveRecord -- Service specific record lookup
43+
)
44+
end
45+
46+
def collect_namespace_ids
47+
denormalized_ids = { self_and_descendant_group_ids: [], all_project_ids: [] }
48+
49+
iterator.each_batch do |ids|
50+
namespaces = Namespace.primary_key_in(ids).select(:id, :type)
51+
namespaces.each do |namespace|
52+
denormalized_attribute = NAMESPACE_TYPE_MAPPING[namespace.type]
53+
denormalized_ids[denormalized_attribute] << namespace.id if denormalized_attribute
54+
end
55+
end
56+
57+
denormalized_ids
58+
end
59+
60+
def iterator
61+
Gitlab::Database::NamespaceEachBatch
62+
.new(namespace_class: Namespace, cursor: { current_id: namespace_id, depth: [namespace_id] })
63+
end
64+
end
65+
end

app/workers/all_queues.yml

+9
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,15 @@
642642
:weight: 1
643643
:idempotent: true
644644
:tags: []
645+
- :name: cronjob:namespaces_process_outdated_namespace_descendants_cron
646+
:worker_name: Namespaces::ProcessOutdatedNamespaceDescendantsCronWorker
647+
:feature_category: :groups_and_projects
648+
:has_external_dependencies: false
649+
:urgency: :low
650+
:resource_boundary: :unknown
651+
:weight: 1
652+
:idempotent: true
653+
:tags: []
645654
- :name: cronjob:namespaces_prune_aggregation_schedules
646655
:worker_name: Namespaces::PruneAggregationSchedulesWorker
647656
:feature_category: :source_code_management
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# frozen_string_literal: true
2+
3+
module Namespaces
4+
class ProcessOutdatedNamespaceDescendantsCronWorker
5+
BATCH_SIZE = 50
6+
7+
include ApplicationWorker
8+
9+
data_consistency :always # rubocop: disable SidekiqLoadBalancing/WorkerDataConsistency -- The worker updates data
10+
11+
# rubocop:disable Scalability/CronWorkerContext -- This worker does not perform work scoped to a context
12+
include CronjobQueue
13+
# rubocop:enable Scalability/CronWorkerContext
14+
15+
feature_category :groups_and_projects
16+
idempotent!
17+
18+
def perform
19+
runtime_limiter = Analytics::CycleAnalytics::RuntimeLimiter.new(45.seconds)
20+
21+
processed_namespaces = 0
22+
loop do
23+
namespace_ids = Namespaces::Descendants.load_outdated_batch(BATCH_SIZE)
24+
25+
break if namespace_ids.empty?
26+
27+
namespace_ids.each do |namespace_id|
28+
Namespaces::UpdateDenormalizedDescendantsService
29+
.new(namespace_id: namespace_id)
30+
.execute
31+
32+
processed_namespaces += 1
33+
break if runtime_limiter.over_time?
34+
end
35+
36+
break if runtime_limiter.over_time?
37+
end
38+
39+
log_extra_metadata_on_done(:result, { processed_namespaces: processed_namespaces })
40+
end
41+
end
42+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: store_object_format
3+
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/419887
4+
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139108
5+
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/434364
6+
milestone: '16.9'
7+
type: gitlab_com_derisk
8+
group: group::source code
9+
default_enabled: false

config/initializers/1_settings.rb

+3
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@
706706
Settings.cron_jobs['ci_catalog_resources_process_sync_events_worker'] ||= {}
707707
Settings.cron_jobs['ci_catalog_resources_process_sync_events_worker']['cron'] ||= '*/1 * * * *'
708708
Settings.cron_jobs['ci_catalog_resources_process_sync_events_worker']['job_class'] = 'Ci::Catalog::Resources::ProcessSyncEventsWorker'
709+
Settings.cron_jobs['namespaces_process_outdated_namespace_descendants_cron_worker'] ||= {}
710+
Settings.cron_jobs['namespaces_process_outdated_namespace_descendants_cron_worker']['cron'] ||= '*/1 * * * *'
711+
Settings.cron_jobs['namespaces_process_outdated_namespace_descendants_cron_worker']['job_class'] = 'Namespaces::ProcessOutdatedNamespaceDescendantsCronWorker'
709712

710713
Gitlab.ee do
711714
Settings.cron_jobs['analytics_devops_adoption_create_all_snapshots_worker'] ||= {}

config/webpack.config.js

-8
Original file line numberDiff line numberDiff line change
@@ -555,14 +555,6 @@ module.exports = {
555555
minChunks: 2,
556556
reuseExistingChunk: true,
557557
},
558-
security_reports: {
559-
priority: 13,
560-
name: 'security_reports',
561-
chunks: 'initial',
562-
test: /[\\/](vue_shared[\\/](security_reports|license_compliance)|security_dashboard)[\\/]/,
563-
minChunks: 2,
564-
reuseExistingChunk: true,
565-
},
566558
vendors: {
567559
priority: 10,
568560
chunks: 'async',

0 commit comments

Comments
 (0)