Skip to content

Commit da10347

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 531cba7 commit da10347

File tree

37 files changed

+1676
-1348
lines changed

37 files changed

+1676
-1348
lines changed

GITLAB_KAS_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
02ff05833da52a69f4c16fa94e539c6f3ab306ea
1+
e8c0552b8152cf9363ccd1d9e9002225904d5202

app/assets/javascripts/admin/users/constants.js

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export const TOKENS = [
7676
unique: true,
7777
options: [{ value: 'placeholder', title: s__('UserMapping|Placeholder') }],
7878
},
79+
{
80+
title: s__('AdminUsers|LDAP sync'),
81+
type: 'ldap_sync',
82+
token: GlFilteredSearchToken,
83+
operators: OPERATORS_IS,
84+
unique: true,
85+
options: [{ value: 'ldap_sync', title: __('True') }],
86+
},
7987
];
8088

8189
export const SOLO_OWNED_ORGANIZATIONS_REQUESTED_COUNT = 10;

app/assets/javascripts/gl_field_errors.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default class GlFieldErrors {
2121
'input[type=email]',
2222
'input[type=url]',
2323
'input[type=number]',
24+
'input[type=tel]',
2425
'textarea',
2526
'select',
2627
].join(',');

app/assets/javascripts/vue_shared/components/users_table/user_avatar.vue

+6-8
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ export default {
7171
<div v-if="user.note" class="gl-p-1 gl-text-subtle">
7272
<gl-icon v-gl-tooltip="userNoteShort" name="document" />
7373
</div>
74-
<div
75-
v-for="(badge, idx) in user.badges"
76-
:key="idx"
77-
class="gl-p-1"
78-
:class="{ 'gl-pb-0': glFeatures.simplifiedBadges }"
79-
>
80-
<gl-badge class="!gl-flex" :variant="badge.variant">{{ badge.text }}</gl-badge>
81-
</div>
8274
</template>
75+
76+
<div class="gl-flex gl-flex-wrap gl-pt-2">
77+
<div v-for="badge in user.badges" :key="badge.text" class="gl-pr-2">
78+
<gl-badge :variant="badge.variant">{{ badge.text }}</gl-badge>
79+
</div>
80+
</div>
8381
</gl-avatar-labeled>
8482
</div>
8583
</template>

app/controllers/admin/users_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def paginate_without_count?
327327
end
328328

329329
def users_with_included_associations(users)
330-
users.includes(:authorized_projects, :trusted_with_spam_attribute) # rubocop: disable CodeReuse/ActiveRecord
330+
users.includes(:authorized_projects, :trusted_with_spam_attribute, :identities) # rubocop: disable CodeReuse/ActiveRecord
331331
end
332332

333333
def admin_making_changes_for_another_user?

app/controllers/concerns/uploads_actions.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ module UploadsActions
1010

1111
UPLOAD_MOUNTS = %w[avatar attachment file logo pwa_icon header_logo favicon screenshot].freeze
1212

13+
# We need to avoid setting certain formats. For example, using the :js format
14+
# would trigger Rails' cross-origin JavaScript protection. To avoid this, we use
15+
# the :text format for JS files instead.
16+
CUSTOM_REQUEST_FORMAT_MAPPING = {
17+
js: :text
18+
}.freeze
19+
1320
included do
1421
prepend_before_action :set_request_format_from_path_extension
1522
rescue_from FileUploader::InvalidSecret, with: :render_404
@@ -85,7 +92,9 @@ def set_request_format_from_path_extension
8592

8693
format = Mime[match.captures.first]
8794

88-
request.format = format.symbol if format
95+
return if format.blank?
96+
97+
request.format = CUSTOM_REQUEST_FORMAT_MAPPING[format.symbol] || format.symbol
8998
end
9099

91100
def content_disposition

app/graphql/resolvers/organizations/organization_users_resolver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def organization_users
2828

2929
def preloads
3030
{
31-
user: [:user]
31+
user: [{ user: [:identities] }]
3232
}
3333
end
3434
end

app/helpers/users_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def user_badges_in_admin_section(user)
141141
badges << { text: s_("AdminUsers|It's you!"), variant: 'muted' } if current_user == user
142142
badges << { text: s_("AdminUsers|Locked"), variant: 'warning' } if user.access_locked?
143143
badges << { text: s_("UserMapping|Placeholder"), variant: 'muted' } if user.placeholder?
144+
badges << { text: s_('AdminUsers|LDAP'), variant: 'info' } if user.ldap_user?
144145
end
145146
end
146147

app/models/user.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ def blocked?
682682
scope :dormant, -> { with_state(:active).human_or_service_user.where('last_activity_on <= ?', Gitlab::CurrentSettings.deactivate_dormant_users_period.day.ago.to_date) }
683683
scope :with_no_activity, -> { with_state(:active).human_or_service_user.where(last_activity_on: nil).where('created_at <= ?', MINIMUM_DAYS_CREATED.day.ago.to_date) }
684684
scope :by_provider_and_extern_uid, ->(provider, extern_uid) { joins(:identities).merge(Identity.with_extern_uid(provider, extern_uid)) }
685+
scope :ldap, -> { joins(:identities).where('identities.provider LIKE ?', 'ldap%') }
685686
scope :by_ids, ->(ids) { where(id: ids) }
686687
scope :by_ids_or_usernames, ->(ids, usernames) { where(username: usernames).or(where(id: ids)) }
687688
scope :without_forbidden_states, -> { where.not(state: FORBIDDEN_SEARCH_STATES) }
@@ -886,12 +887,14 @@ def filter_items(filter_name)
886887
without_projects
887888
when 'external'
888889
external
889-
when "trusted"
890+
when 'trusted'
890891
trusted
891-
when "placeholder"
892+
when 'placeholder'
892893
placeholder
893-
when "without_placeholders"
894+
when 'without_placeholders'
894895
without_placeholders
896+
when 'ldap_sync'
897+
ldap
895898
else
896899
all_without_ghosts
897900
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: duo_code_review_full_file
3+
description:
4+
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/510266
5+
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/189314
6+
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/537556
7+
milestone: '18.0'
8+
group: group::code review
9+
type: beta
10+
default_enabled: false

config/feature_flags/development/invitation_flow_enforcement_setting.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92218
44
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/367666
55
milestone: '15.4'
66
type: development
7-
group: group::organizations
7+
group: group::authorization
88
default_enabled: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
migration_job_name: BackfillResourceIterationEventsNamespaceId
3+
description: Backfills sharding key for resource_iteration_events.namespace_id
4+
feature_category: team_planning
5+
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/187487
6+
milestone: '17.11'
7+
queued_migration_version: 20250409172701
8+
finalized_by: # version of the migration that finalized this BBM
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
class QueueBackfillResourceIterationEventsNamespaceId < Gitlab::Database::Migration[2.2]
4+
milestone '17.11'
5+
6+
restrict_gitlab_migration gitlab_schema: :gitlab_main
7+
8+
MIGRATION = "BackfillResourceIterationEventsNamespaceId"
9+
DELAY_INTERVAL = 2.minutes
10+
BATCH_SIZE = 10000
11+
SUB_BATCH_SIZE = 100
12+
13+
def up
14+
queue_batched_background_migration(
15+
MIGRATION,
16+
:resource_iteration_events,
17+
:id,
18+
job_interval: DELAY_INTERVAL,
19+
batch_size: BATCH_SIZE,
20+
sub_batch_size: SUB_BATCH_SIZE
21+
)
22+
end
23+
24+
def down
25+
delete_batched_background_migration(MIGRATION, :resource_iteration_events, :id, [])
26+
end
27+
end

db/schema_migrations/20250409172701

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

doc/development/database/ci_mirrored_tables.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: CI mirrored tables
1010
As part of the database [decomposition work](https://gitlab.com/groups/gitlab-org/-/epics/6168),
1111
which had the goal of splitting the single database GitLab is using, into two databases: `main` and
1212
`ci`, came the big challenge of
13-
[removing all joins between the `main` and the `ci` tables](multiple_databases.md#removing-joins-between-ci-and-non-ci-tables).
13+
[removing all joins between the `main` and the `ci` tables](multiple_databases.md#removing-joins-between-main-and-non-main-tables).
1414
That is because PostgreSQL doesn't support joins between tables that belong to different databases.
1515
However, some core application models in the main database are queried very often by the CI side.
1616
For example:

doc/development/database/multiple_databases.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Multiple Databases
77

88
To allow GitLab to scale further we
99
[decomposed the GitLab application database into multiple databases](https://gitlab.com/groups/gitlab-org/-/epics/6168).
10-
The main databases are `main`, `ci`, and (optionally) `sec`. GitLab supports being run with one, two, or three databases.
10+
The main databases are `main`, `ci`, and `sec`. GitLab supports being run with one, two, or three databases.
1111
On GitLab.com we are using separate `main` `ci`, and `sec` databases.
1212

1313
For the purpose of building the [Cells](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/cells/) architecture, we are decomposing
@@ -68,7 +68,7 @@ The `gitlab_schema` primary purpose is to introduce a barrier between different
6868

6969
This is used as a primary source of classification for:
7070

71-
- [Discovering cross-joins across tables from different schemas](#removing-joins-between-ci-and-non-ci-tables)
71+
- [Discovering cross-joins across tables from different schemas](#removing-joins-between-main-and-non-main-tables)
7272
- [Discovering cross-database transactions across tables from different schemas](#removing-cross-database-transactions)
7373

7474
### The special purpose of `gitlab_shared`
@@ -102,7 +102,7 @@ might be missing some of those application-defined `gitlab_shared` tables (like
102102

103103
Read [Migrations for Multiple Databases](migrations_for_multiple_databases.md).
104104

105-
## CI/CD Database
105+
## CI and Sec Databases
106106

107107
### Configure single database
108108

@@ -111,7 +111,7 @@ By default, GDK is configured to run with multiple databases.
111111
{{< alert type="warning" >}}
112112

113113
Switching back-and-forth between single and multiple databases in
114-
the same development instance is discouraged. Any data in the `ci`
114+
the same development instance is discouraged. Any data in the `ci` or `sec`
115115
database will not be accessible in single database mode. For single database, you should use a separate development instance.
116116

117117
{{< /alert >}}
@@ -122,6 +122,7 @@ To configure GDK to use a single database:
122122

123123
```shell
124124
gdk config set gitlab.rails.databases.ci.enabled false
125+
gdk config set gitlab.rails.databases.sec.enabled false
125126
```
126127

127128
1. Reconfigure GDK:
@@ -130,21 +131,21 @@ To configure GDK to use a single database:
130131
gdk reconfigure
131132
```
132133

133-
To switch back to using multiple databases, set `gitlab.rails.databases.ci.enabled` to `true` and run `gdk reconfigure`.
134+
To switch back to using multiple databases, set `gitlab.rails.databases.<db_name>.enabled` to `true` and run `gdk reconfigure`.
134135

135136
<!--
136137
The `validate_cross_joins!` method in `spec/support/database/prevent_cross_joins.rb` references
137138
the following heading in the code, so if you make a change to this heading, make sure to update
138139
the corresponding documentation URL used in `spec/support/database/prevent_cross_joins.rb`.
139140
-->
140141

141-
### Removing joins between `ci` and non `ci` tables
142+
### Removing joins between `main` and non `main` tables
142143

143144
Queries that join across databases raise an error. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68620)
144145
in GitLab 14.3, for new queries only. Pre-existing queries do not raise an error.
145146

146-
Because GitLab can be run with multiple separate databases, referencing `ci`
147-
tables with non `ci` tables in a single query is not possible. Therefore,
147+
Because GitLab can be run with multiple separate databases, referencing `main`
148+
tables with non `main` tables in a single query is not possible. Therefore,
148149
using any kind of `JOIN` in SQL queries will not work.
149150

150151
#### Suggestions for removing cross-database joins
@@ -296,28 +297,28 @@ met:
296297
1. The data does not update often (for example, the `project_id` column is almost
297298
never updated for most tables).
298299

299-
One example we found was the `security_scans` table. This table has a foreign
300-
key `security_scans.build_id` which allows you to join to the build. Therefore
300+
One example we found was the `terraform_state_versions` table. This table has a foreign
301+
key `terraform_state_versions.ci_build_id` which allows you to join to the build. Therefore
301302
you could join to the project like so:
302303

303304
```sql
304-
select projects.* from security_scans
305-
inner join ci_builds on security_scans.build_id = ci_builds.id
305+
select projects.* from terraform_state_versions
306+
inner join ci_builds on terraform_state_versions.ci_build_id = ci_builds.id
306307
inner join projects on ci_builds.project_id = projects.id
307308
```
308309

309310
The problem with this query is that `ci_builds` is in a different database
310311
from the other two tables.
311312

312313
The solution in this case is to add the `project_id` column to
313-
`security_scans`. This doesn't use much extra storage, and due to the way
314+
`terraform_state_versions`. This doesn't use much extra storage, and due to the way
314315
these features work, it's never updated (a build never moves projects).
315316

316317
This simplified the query to:
317318

318319
```sql
319-
select projects.* from security_scans
320-
inner join projects on security_scans.project_id = projects.id
320+
select projects.* from terraform_state_versions
321+
inner join projects on terraform_state_versions.project_id = projects.id
321322
```
322323

323324
This also improves performance because you don't need to join through an extra
@@ -754,12 +755,13 @@ to limit the modes where tests can run, and skip them on any other modes.
754755

755756
## Locking writes on the tables that don't belong to the database schemas
756757

757-
When the CI database is promoted and the two databases are fully split,
758+
When a separate database is promoted and the split from main,
758759
as an extra safeguard against creating a split brain situation,
759760
run the Rake task `gitlab:db:lock_writes`. This command locks writes on:
760761

761-
- The `gitlab_main` tables on the CI Database.
762-
- The `gitlab_ci` tables on the Main Database.
762+
- Legacy tables on `gitlab_ci` belonging to the Main or Sec Databases.
763+
- Legacy tables on `gitlab_main` belonging to the CI or Sec Databases.
764+
- Legacy tables on `gitlab_sec` belonging to the CI or Main Databases.
763765

764766
This Rake task adds triggers to all the tables, to prevent any
765767
`INSERT`, `UPDATE`, `DELETE`, or `TRUNCATE` statements from running
@@ -832,7 +834,7 @@ end
832834

833835
## Truncating tables
834836

835-
When the databases `main` and `ci` are fully split, we can free up disk
837+
When separate databases from `main` are fully split, we can free up disk
836838
space by truncating tables. This results in a smaller data set: For example,
837839
the data in `users` table on CI database is no longer read and also no
838840
longer updated. So this data can be removed by truncating the tables.

0 commit comments

Comments
 (0)