Commit 08ed6a86 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent b0f27742
......@@ -262,8 +262,6 @@ class MergeRequest < ApplicationRecord
RebaseLockTimeout = Class.new(StandardError)
REBASE_LOCK_MESSAGE = _("Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.")
def self.reference_prefix
'!'
end
......@@ -1514,7 +1512,7 @@ class MergeRequest < ApplicationRecord
end
rescue ActiveRecord::LockWaitTimeout => e
Gitlab::ErrorTracking.track_exception(e)
raise RebaseLockTimeout, REBASE_LOCK_MESSAGE
raise RebaseLockTimeout, _('Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.')
end
def source_project_variables
......
......@@ -7,7 +7,8 @@ class ProjectWiki
MARKUPS = {
'Markdown' => :markdown,
'RDoc' => :rdoc,
'AsciiDoc' => :asciidoc
'AsciiDoc' => :asciidoc,
'Org' => :org
}.freeze unless defined?(MARKUPS)
CouldNotCreateWikiError = Class.new(StandardError)
......
---
title: Fix rebase error message translation in merge requests
merge_request: 22952
author: briankabiro
type: fixed
---
title: Add Org to the list of available markups for project wikis
merge_request: 22898
author: Alexander Oleynikov
type: added
# frozen_string_literal: true
# when running on puma, scale connection pool size with the number
# of threads per worker process
if Gitlab::Runtime.puma?
def log_pool_size(db, previous_pool_size, current_pool_size)
log_message = ["#{db} connection pool size: #{current_pool_size}"]
if previous_pool_size && current_pool_size > previous_pool_size
log_message << "(increased from #{previous_pool_size} to match thread count)"
end
Gitlab::AppLogger.debug(log_message.join(' '))
end
# When running on multi-threaded runtimes like Puma or Sidekiq,
# set the number of threads per process as the minimum DB connection pool size.
# This is to avoid connectivity issues as was documented here:
# https://github.com/rails/rails/pull/23057
if Gitlab::Runtime.multi_threaded?
max_threads = Gitlab::Runtime.max_threads
db_config = Gitlab::Database.config ||
Rails.application.config.database_configuration[Rails.env]
puma_options = Puma.cli_config.options
previous_db_pool_size = db_config['pool']
# We use either the maximum number of threads per worker process, or
# the user specified value, whichever is larger.
desired_pool_size = [db_config['pool'].to_i, puma_options[:max_threads]].max
db_config['pool'] = [db_config['pool'].to_i, max_threads].max
db_config['pool'] = desired_pool_size
# recreate the connection pool from the new config
ActiveRecord::Base.establish_connection(db_config)
current_db_pool_size = ActiveRecord::Base.connection.pool.size
log_pool_size('DB', previous_db_pool_size, current_db_pool_size)
Gitlab.ee do
if Gitlab::Runtime.sidekiq? && Gitlab::Geo.geo_database_configured?
previous_geo_db_pool_size = Rails.configuration.geo_database['pool']
Rails.configuration.geo_database['pool'] = max_threads
Geo::TrackingBase.establish_connection(Rails.configuration.geo_database)
current_geo_db_pool_size = Geo::TrackingBase.connection_pool.size
log_pool_size('Geo DB', previous_geo_db_pool_size, current_geo_db_pool_size)
end
end
end
......@@ -88,23 +88,10 @@ Sidekiq.configure_server do |config|
Gitlab::SidekiqVersioning.install!
db_config = Gitlab::Database.config ||
Rails.application.config.database_configuration[Rails.env]
db_config['pool'] = Sidekiq.options[:concurrency]
ActiveRecord::Base.establish_connection(db_config)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") # rubocop:disable Gitlab/RailsLogger
Gitlab.ee do
Gitlab::Mirror.configure_cron_job!
Gitlab::Geo.configure_cron_jobs!
if Gitlab::Geo.geo_database_configured?
Rails.configuration.geo_database['pool'] = Sidekiq.options[:concurrency]
Geo::TrackingBase.establish_connection(Rails.configuration.geo_database)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{Geo::TrackingBase.connection_pool.size} (Geo tracking database)") # rubocop:disable Gitlab/RailsLogger
end
end
# Avoid autoload issue such as 'Mail::Parsers::AddressStruct'
......
......@@ -86,7 +86,7 @@ POST /projects/:id/wikis
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `content` | string | yes | The content of the wiki page |
| `title` | string | yes | The title of the wiki page |
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc`, and `asciidoc` |
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc`, `asciidoc` and `org` |
```bash
curl --data "format=rdoc&title=Hello&content=Hello world" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis"
......@@ -116,7 +116,7 @@ PUT /projects/:id/wikis/:slug
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `content` | string | yes if `title` is not provided | The content of the wiki page |
| `title` | string | yes if `content` is not provided | The title of the wiki page |
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc`, and `asciidoc` |
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc`, `asciidoc` and `org` |
| `slug` | string | yes | The slug (a unique string) of the wiki page |
```bash
......
......@@ -26,7 +26,7 @@ it to GitLab, you have the option to create a **Merge Request**,
which is essentially a _request_ to merge one branch into another.
The branch you added your changes into is called _source branch_
while the branch you'll request to merge your changes into is
while the branch you request to merge your changes into is
called _target branch_.
The target branch can be the default or any other branch, depending
......@@ -46,19 +46,18 @@ Learn the various ways to [create a merge request](creating_merge_requests.md).
## What you can do with merge requests
When you start a new merge request, you'll have the following
options to include straightaway (you can also add them later by
clicking the **Edit** button on the merge request's page at the
top-right side):
When you start a new merge request, you can immediately include the following
options, or add them later by clicking the **Edit** button on the merge
request's page at the top-right side:
- [Assign](#assignee) the merge request to a colleague for review.With GitLab Starter and higher tiers, you can [assign it to more than one person at a time](#multiple-assignees-starter).
- [Assign](#assignee) the merge request to a colleague for review. With GitLab Starter and higher tiers, you can [assign it to more than one person at a time](#multiple-assignees-starter).
- Set a [milestone](../milestones/index.md) to track time-sensitive changes.
- Add [labels](../labels.md) to help contextualize and filter your merge requests over time.
- Require [approval](merge_request_approvals.md) from your team. **(STARTER)**
- [Close issues automatically](#merge-requests-to-close-issues) when it's merged.
- [Close issues automatically](#merge-requests-to-close-issues) when they are merged.
- Enable the [delete source branch when merge request is accepted](#deleting-the-source-branch) option to keep your repository clean.
- Enable the [squash commits when merge request is accepted](squash_and_merge.md) option to combine all the commits into one before merging, thus keep a clean commit history in your repository.
- Set the merge request as a [Work In Progress (WIP)](work_in_progress_merge_requests.md) to avoid accidental merges before it's ready.
- Set the merge request as a [Work In Progress (WIP)](work_in_progress_merge_requests.md) to avoid accidental merges before it is ready.
Once you have created the merge request, you can also:
......@@ -98,12 +97,13 @@ to indicate everyone that is reviewing or accountable for it.
To assign multiple assignees to a merge request:
1. From a merge request, expand the right sidebar and locate the **Assignees** section.
1. Click on **Edit** and from the dropdown menu, select as many users as you want to assign the merge request to.
1. Click on **Edit** and from the dropdown menu, select as many users as you want
to assign the merge request to.
Similarly, assignees are removed by deselecting them from the same
dropdown menu.
It's also possible to manage multiple assignees:
It is also possible to manage multiple assignees:
- When creating a merge request.
- Using [quick actions](../quick_actions.md#quick-actions-for-issues-merge-requests-and-epics).
......@@ -111,7 +111,7 @@ It's also possible to manage multiple assignees:
### Merge requests to close issues
If the merge request is being created to resolve an issue, you can
add a note in the description which will set it to
add a note in the description which sets it to
[automatically close the issue](../issues/managing_issues.md#closing-issues-automatically)
when merged.
......@@ -122,27 +122,30 @@ to prevent confidential information from being exposed.
### Deleting the source branch
When creating a merge request, select the "Delete source branch
when merge request accepted" option and the source branch will be
deleted when the merge request is merged. To make this option
When creating a merge request, select the
**Delete source branch when merge request accepted** option, and the source
branch is deleted when the merge request is merged. To make this option
enabled by default for all new merge requests, enable it in the
[project's settings](../settings/index.md#merge-request-settings).
This option is also visible in an existing merge request next to
the merge request button and can be selected/deselected before merging.
It's only visible to users with [Maintainer permissions](../../permissions.md)
the merge request button and can be selected or deselected before merging.
It is only visible to users with [Maintainer permissions](../../permissions.md)
in the source project.
If the user viewing the merge request does not have the correct
permissions to delete the source branch and the source branch
is set for deletion, the merge request widget will show the
is set for deletion, the merge request widget displays the
**Deletes source branch** text.
![Delete source branch status](img/remove_source_branch_status.png)
## Recommendations and best practices for Merge Requests
- When working locally in your branch, add multiple commits and only push when you're done, so GitLab will run only one pipeline for all the commits pushed at once. By doing so, you save pipeline minutes.
- When working locally in your branch, add multiple commits and only push when
you're done, so GitLab runs only one pipeline for all the commits pushed
at once. By doing so, you save pipeline minutes.
- Delete feature branches on merge or after merging them to keep your repository clean.
- Take one thing at a time and ship the smallest changes possible. By doing so, you'll have faster reviews and your changes will be less prone to errors.
- Don't use capital letters nor special chars in branch names.
- Take one thing at a time and ship the smallest changes possible. By doing so,
you'll have faster reviews and your changes will be less prone to errors.
- Do not use capital letters nor special chars in branch names.
......@@ -38,7 +38,7 @@ automatically. For example, a title of `docs/my-page` will create a wiki
page with a path `/wikis/docs/my-page`.
Once you enter the page name, it's time to fill in its content. GitLab wikis
support Markdown, RDoc and AsciiDoc. For Markdown based pages, all the
support Markdown, RDoc, AsciiDoc and Org. For Markdown based pages, all the
[Markdown features](../../markdown.md) are supported and for links there is
some [wiki specific](../../markdown.md#wiki-specific-markdown) behavior.
......
......@@ -26,7 +26,7 @@ module API
type: String,
values: ProjectWiki::MARKUPS.values.map(&:to_s),
default: 'markdown',
desc: 'Format of a wiki page. Available formats are markdown, rdoc, and asciidoc'
desc: 'Format of a wiki page. Available formats are markdown, rdoc, asciidoc and org'
end
end
......
......@@ -18,7 +18,7 @@ module Gitlab
:committed_date, :committer_name, :committer_email
].freeze
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
attr_accessor(*SERIALIZE_KEYS)
def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit)
......
......@@ -10,7 +10,7 @@ module Gitlab
MAX_TAG_MESSAGE_DISPLAY_SIZE = 10.megabytes
SERIALIZE_KEYS = %i[name target target_commit message].freeze
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
attr_accessor(*SERIALIZE_KEYS)
class << self
def get_message(repository, tag_id)
......
......@@ -67,6 +67,16 @@ module Gitlab
def process_name
File.basename($0)
end
def max_threads
if puma?
Puma.cli_config.options[:max_threads]
elsif sidekiq?
Sidekiq.options[:concurrency]
else
1
end
end
end
end
end
......@@ -4,12 +4,9 @@ module QA
context 'Plan' do
describe 'Close issue' do
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.title = 'Issue to be closed via pushing a commit'
end
Resource::Issue.fabricate_via_api!
end
let(:project) { issue.project }
let(:issue_id) { issue.api_response[:iid] }
before do
......@@ -39,7 +36,7 @@ module QA
push.commit_message = commit_message
push.new_branch = new_branch
push.file_content = commit_message
push.project = project
push.project = issue.project
end
end
end
......
......@@ -1412,7 +1412,7 @@ describe Projects::MergeRequestsController do
post_rebase
expect(response.status).to eq(409)
expect(json_response['merge_error']).to eq(MergeRequest::REBASE_LOCK_MESSAGE)
expect(json_response['merge_error']).to eq('Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.')
end
end
......
......@@ -145,6 +145,24 @@ describe "User creates wiki page" do
end
end
it 'creates a wiki page with Org markup', :aggregate_failures do
org_content = <<~ORG
* Heading
** Subheading
[[home][Link to Home]]
ORG
page.within('.wiki-form') do
find('#wiki_format option[value=org]').select_option
fill_in(:wiki_content, with: org_content)
click_button('Create page')
end
expect(page).to have_selector('h1', text: 'Heading')
expect(page).to have_selector('h2', text: 'Subheading')
expect(page).to have_link('Link to Home', href: "/#{project.full_path}/-/wikis/home")
end
it_behaves_like 'wiki file attachments', :quarantine
end
......
......@@ -11,14 +11,12 @@ describe 'Database config initializer' do
allow(ActiveRecord::Base).to receive(:establish_connection)
end
context "when using Puma" do
let(:puma) { double('puma') }
let(:puma_options) { { max_threads: 8 } }
context "when using multi-threaded runtime" do
let(:max_threads) { 8 }
before do
allow(Gitlab::Runtime).to receive(:puma?).and_return(true)
stub_const("Puma", puma)
allow(puma).to receive_message_chain(:cli_config, :options).and_return(puma_options)
allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(true)
allow(Gitlab::Runtime).to receive(:max_threads).and_return(max_threads)
end
context "and no existing pool size is set" do
......@@ -27,23 +25,23 @@ describe 'Database config initializer' do
end
it "sets it to the max number of worker threads" do
expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(8)
expect { subject }.to change { Gitlab::Database.config['pool'] }.from(nil).to(max_threads)
end
end
context "and the existing pool size is smaller than the max number of worker threads" do
before do
stub_database_config(pool_size: 7)
stub_database_config(pool_size: max_threads - 1)
end
it "sets it to the max number of worker threads" do
expect { subject }.to change { Gitlab::Database.config['pool'] }.from(7).to(8)
expect { subject }.to change { Gitlab::Database.config['pool'] }.by(1)
end
end
context "and the existing pool size is larger than the max number of worker threads" do
before do
stub_database_config(pool_size: 9)
stub_database_config(pool_size: max_threads + 1)
end
it "keeps the configured pool size" do
......@@ -52,11 +50,7 @@ describe 'Database config initializer' do
end
end
context "when not using Puma" do
before do
stub_database_config(pool_size: 7)
end
context "when using single-threaded runtime" do
it "does nothing" do
expect { subject }.not_to change { Gitlab::Database.config['pool'] }
end
......
......@@ -26,9 +26,15 @@ describe Gitlab::Runtime do
context "puma" do
let(:puma_type) { double('::Puma') }
let(:options) do
{
max_threads: 2
}
end
before do
stub_const('::Puma', puma_type)
allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(options)
end
it "identifies itself" do
......@@ -43,6 +49,10 @@ describe Gitlab::Runtime do
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(2)
end
end
context "unicorn" do
......@@ -66,14 +76,24 @@ describe Gitlab::Runtime do
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
end
context "sidekiq" do
let(:sidekiq_type) { double('::Sidekiq') }
let(:options) do
{
concurrency: 2
}
end
before do
stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true)
allow(sidekiq_type).to receive(:options).and_return(options)
end
it "identifies itself" do
......@@ -88,6 +108,10 @@ describe Gitlab::Runtime do
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(2)
end
end
context "console" do
......@@ -109,6 +133,10 @@ describe Gitlab::Runtime do
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
end
context "rspec" do
......@@ -127,5 +155,9 @@ describe Gitlab::Runtime do
expect(subject.rake?).to be(false)
expect(subject.puma?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
end
end
......@@ -2260,7 +2260,7 @@ describe API::MergeRequests do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/rebase", user)
expect(response).to have_gitlab_http_status(409)
expect(json_response['message']).to eq(MergeRequest::REBASE_LOCK_MESSAGE)
expect(json_response['message']).to eq('Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment