Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-07-07 03:09:39 +00:00
parent db30e094f2
commit f06d16d23c
7 changed files with 140 additions and 3 deletions

View file

@ -22,6 +22,10 @@ Using serializers, instead of `to_json` method, has several benefits:
* it makes it easier to reduce merge conflicts between CE -> EE * it makes it easier to reduce merge conflicts between CE -> EE
* it makes it easier to benefit from domain driven development techniques * it makes it easier to benefit from domain driven development techniques
## Security considerations
Consult the `Serialization` section of our [Secure Coding Guidelines](../../doc/development/secure_coding_guidelines.md#serialization) to help avoiding leaking sensitive attributes when using serializers.
## What is a serializer? ## What is a serializer?
A serializer is a class that encapsulates all business rules for building a A serializer is a class that encapsulates all business rules for building a

View file

@ -5,7 +5,10 @@ module Projects
def execute(fork_to_project = nil) def execute(fork_to_project = nil)
forked_project = fork_to_project ? link_existing_project(fork_to_project) : fork_new_project forked_project = fork_to_project ? link_existing_project(fork_to_project) : fork_new_project
refresh_forks_count if forked_project&.saved? if forked_project&.saved?
refresh_forks_count
stream_audit_event(forked_project)
end
forked_project forked_project
end end
@ -133,5 +136,11 @@ module Projects
def target_mr_default_target_self def target_mr_default_target_self
@target_mr_default_target_self ||= params[:mr_default_target_self] @target_mr_default_target_self ||= params[:mr_default_target_self]
end end
def stream_audit_event(forked_project)
# Defined in EE
end end
end end
end
Projects::ForkService.prepend_mod

View file

@ -1,6 +1,6 @@
= form_for [@project, @milestone], = form_for [@project, @milestone],
html: { class: 'milestone-form common-note-form js-quick-submit js-requires-input' } do |f| html: { class: 'milestone-form common-note-form js-quick-submit js-requires-input' } do |f|
= form_errors(@milestone) = form_errors(@milestone, pajamas_alert: true)
.form-group.row .form-group.row
.col-form-label.col-sm-2 .col-form-label.col-sm-2
= f.label :title, _('Title') = f.label :title, _('Title')

View file

@ -555,3 +555,52 @@ X-Gitlab-Event-Streaming-Token: <DESTINATION_TOKEN>
"event_type": "merge_request_create" "event_type": "merge_request_create"
} }
``` ```
## Audit event streaming on project fork actions
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90916) in GitLab 15.2.
Stream audit events that relate to project fork actions using the `/logs` endpoint.
Send API requests that contain the `X-Gitlab-Audit-Event-Type` header with value `project_fork_operation`. GitLab responds with JSON payloads with an
`event_type` field set to `project_fork_operation`.
### Headers
Headers are formatted as follows:
```plaintext
POST /logs HTTP/1.1
Host: <DESTINATION_HOST>
Content-Type: application/x-www-form-urlencoded
X-Gitlab-Audit-Event-Type: project_fork_operation
X-Gitlab-Event-Streaming-Token: <DESTINATION_TOKEN>
```
### Example payload
```json
{
"id": 1,
"author_id": 1,
"entity_id": 24,
"entity_type": "Project",
"details": {
"author_name": "example_username",
"target_id": 24,
"target_type": "Project",
"target_details": "example-project",
"custom_message": "Forked project to another-group/example-project-forked",
"ip_address": "127.0.0.1",
"entity_path": "example-group/example-project"
},
"ip_address": "127.0.0.1",
"author_name": "example_username",
"entity_path": "example-group/example-project",
"target_details": "example-project",
"created_at": "2022-06-30T03:43:35.384Z",
"target_type": "Project",
"target_id": 24,
"event_type": "project_fork_operation"
}
```

View file

@ -0,0 +1,65 @@
---
stage: Data Stores
group: Database
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Moving GitLab databases to a different PostgreSQL instance **(FREE SELF)**
Sometimes it is necessary to move your databases from one PostgreSQL instance to
another. For example, if you are using AWS Aurora and are preparing to
enable Database Load Balancing, you will need to move your databases to
RDS for PostgreSQL.
To move databases from one instance to another:
1. Gather the source and destination PostgreSQL endpoint information:
```shell
SRC_PGHOST=<source postgresql host>
SRC_PGUSER=<source postgresql user>
DST_PGHOST=<destination postgresql host>
DST_PGUSER=<destination postgresql user>
```
1. Stop GitLab:
```shell
sudo gitlab-ctl stop
```
1. Dump the databases from the source:
```shell
/opt/gitlab/embedded/bin/pg_dump -h $SRC_PGHOST -U $SRC_PGUSER -c -C -f gitlabhq_production.sql gitlabhq_production
/opt/gitlab/embedded/bin/pg_dump -h $SRC_PGHOST -U $SRC_PGUSER -c -C -f praefect_production.sql praefect_production
```
1. Restore the databases to the destination (this will overwrite any existing databases with the same names):
```shell
/opt/gitlab/embedded/bin/psql -h $DST_PGHOST -U $DST_PGUSER -f praefect_production.sql postgres
/opt/gitlab/embedded/bin/psql -h $DST_PGHOST -U $DST_PGUSER -f gitlabhq_production.sql postgres
```
1. Configure the GitLab application servers with the appropriate connection details
for your destination PostgreSQL instance in your `/etc/gitlab/gitlab.rb` file:
```ruby
gitlab_rails['db_host'] = '<destination postgresql host>'
```
For more information on GitLab multi-node setups, refer to the [reference architectures](../reference_architectures/index.md).
1. Reconfigure for the changes to take effect:
```shell
sudo gitlab-ctl reconfigure
```
1. Restart GitLab:
```shell
sudo gitlab-ctl start
```

View file

@ -51,7 +51,7 @@ RSpec.describe 'Milestone' do
end end
find('input[name="commit"]').click find('input[name="commit"]').click
expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.') expect(find('.gl-alert-danger')).to have_content('already being used for another group or project milestone.')
end end
it 'displays validation message when there is a group milestone with same title' do it 'displays validation message when there is a group milestone with same title' do

View file

@ -454,6 +454,16 @@ RSpec.describe Gitlab::BackgroundMigration::RecalculateVulnerabilitiesOccurrence
allow(Gitlab::ErrorTracking).to receive(:track_and_raise_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_exception)
expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_exception).with(expected_error).once expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_exception).with(expected_error).once
end end
it_behaves_like 'marks background migration job records' do
let(:arguments) { [1, 4] }
subject { described_class.new }
end
end
it_behaves_like 'marks background migration job records' do
let(:arguments) { [1, 4] }
subject { described_class.new }
end end
private private