Commit e7b5a68d authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@13-3-stable-ee

parent c8fb2e6a
......@@ -63,7 +63,7 @@ export default {
return this.actions.length > 0;
},
hasValidBlobs() {
return this.actions.every(x => x.filePath && x.content);
return this.actions.every(x => x.content);
},
updatePrevented() {
return this.snippet.title === '' || !this.hasValidBlobs || this.isUpdating;
......
......@@ -123,7 +123,7 @@ class GroupsController < Groups::ApplicationController
if Groups::UpdateService.new(@group, current_user, group_params).execute
redirect_to edit_group_path(@group, anchor: params[:update_section]), notice: "Group '#{@group.name}' was successfully updated."
else
@group.path = @group.path_before_last_save || @group.path_was
@group.reset
render action: "edit"
end
end
......
......@@ -7,7 +7,21 @@ module Resolvers
type Types::IssueStatusCountsType, null: true
def continue_issue_resolve(parent, finder, **args)
finder.params[parent_param(parent)] = parent if parent
Gitlab::IssuablesCountForState.new(finder, parent)
end
private
def parent_param(parent)
case parent
when Project
:project_id
when Group
:group_id
else
raise "Unexpected type of parent: #{parent.class}. Must be Project or Group"
end
end
end
end
---
title: Scope incident issue counts by given project or group
merge_request: 40700
author:
type: fixed
---
title: Fix snippet save button disabled with empty file path
merge_request: 40412
author:
type: fixed
---
title: Fix race condition in concurrent backups
merge_request: 39894
author:
type: fixed
---
title: Display upcoming database deprecation warning only if current database version minimum is not met
merge_request: 38225
author:
type: removed
---
title: Prevent accidental group deletion if path rename fails
merge_request: 40353
author:
type: fixed
---
title: Fix exception handling when a concurrent backup fails
merge_request: 40451
author:
type: fixed
......@@ -940,6 +940,9 @@ cluster.
## Distributed reads
> - Introduced in GitLab 13.1 in [beta](https://about.gitlab.com/handbook/product/gitlab-the-product/#alpha-beta-ga) with feature flag `gitaly_distributed_reads` set to disabled.
> - [Made generally available](https://gitlab.com/gitlab-org/gitaly/-/issues/2951) in GitLab 13.3.
Praefect supports distribution of read operations across Gitaly nodes that are
configured for the virtual node.
......
......@@ -744,7 +744,11 @@ so `&&` is evaluated before `||`.
#### Parentheses
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3
> - It's deployed behind a feature flag, enabled by default.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-parenthesis-support-for-variables-core-only). **(CORE ONLY)**
It is possible to use parentheses to group conditions. Parentheses have the highest
precedence of all operators. Expressions enclosed in parentheses are evaluated first,
......@@ -760,20 +764,22 @@ Examples:
- `($VARIABLE1 =~ /^content.*/ || $VARIABLE2 =~ /thing$/) && $VARIABLE3`
- `$CI_COMMIT_BRANCH == "my-branch" || (($VARIABLE1 == "thing" || $VARIABLE2 == "thing") && $VARIABLE3)`
##### Enable or disable parenthesis support for variables **(CORE ONLY)**
The feature is currently deployed behind a feature flag that is **enabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to disable it for your instance.
To enable it:
To disable it:
```ruby
Feature.enable(:ci_if_parenthesis_enabled)
Feature.disable(:ci_if_parenthesis_enabled)
```
To disable it:
To enable it:
```ruby
Feature.disable(:ci_if_parenthesis_enabled)
Feature.enable(:ci_if_parenthesis_enabled)
```
### Storing regular expressions in variables
......
......@@ -1548,6 +1548,22 @@ considered for their usage and behavior in this context. Future keyword improvem
are being discussed in our [epic for improving `rules`](https://gitlab.com/groups/gitlab-org/-/epics/2783),
where anyone can add suggestions or requests.
You can use [parentheses](../variables/README.md#parentheses) with `&&` and `||` to build more complicated variable expressions.
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3:
```yaml
job1:
script:
- echo This rule uses parentheses.
rules:
if: ($CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE
```
NOTE: **Note:**
In GitLab 13.2 and older, the order of operations when mixing `||` and `&&` in a single rule may not have executed
in the expected order. This is [fixed](https://gitlab.com/gitlab-org/gitlab/-/issues/230938)
in GitLab 13.3.
### `only`/`except` (basic)
NOTE: **Note:**
......@@ -1833,7 +1849,17 @@ end-to-end:
- $CI_COMMIT_MESSAGE =~ /skip-end-to-end-tests/
```
Learn more about [variables expressions](../variables/README.md#environment-variables-expressions).
You can use [parentheses](../variables/README.md#parentheses) with `&&` and `||` to build more complicated variable expressions.
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3:
```yaml
job1:
script:
- echo This rule uses parentheses.
only:
variables:
- ($CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE
```
#### `only:changes`/`except:changes`
......
......@@ -11,7 +11,7 @@ as the hardware requirements that are needed to install and use GitLab.
### Supported Linux distributions
- Ubuntu (16.04/18.04)
- Ubuntu (16.04/18.04/20.04)
- Debian (8/9/10)
- CentOS (6/7/8)
- openSUSE (Leap 15.1/Enterprise Server 12.2)
......
......@@ -26,13 +26,17 @@ module Backup
threads = Gitlab.config.repositories.storages.keys.map do |storage|
Thread.new do
dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency)
rescue => e
errors << e
Rails.application.executor.wrap do
dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency)
rescue => e
errors << e
end
end
end
threads.each(&:join)
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
threads.each(&:join)
end
raise errors.pop unless errors.empty?
end
......@@ -155,16 +159,18 @@ module Backup
threads = Array.new(max_storage_concurrency) do
Thread.new do
while project = queue.pop
semaphore.acquire
begin
dump_project(project)
rescue => e
errors << e
break
ensure
semaphore.release
Rails.application.executor.wrap do
while project = queue.pop
semaphore.acquire
begin
dump_project(project)
rescue => e
errors << e
break
ensure
semaphore.release
end
end
end
end
......@@ -176,10 +182,12 @@ module Backup
queue.push(project)
end
queue.close
threads.each(&:join)
raise errors.pop unless errors.empty?
ensure
queue.close
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
threads.each(&:join)
end
end
def dump_project(project)
......
......@@ -6,48 +6,21 @@ module Gitlab
extend self
def check
notices = []
unless Gitlab::Database.postgresql_minimum_supported_version?
string_args = {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url_open: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">'.html_safe,
pg_requirements_url_close: '</a>'.html_safe
return [] if Gitlab::Database.postgresql_minimum_supported_version?
[
{
type: 'warning',
message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url} for details.') % {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
}
}
notices <<
{
type: 'warning',
message: html_escape(_('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details.')) % string_args
}
end
if Gitlab::Database.postgresql_upcoming_deprecation? && Gitlab::Database.within_deprecation_notice_window?
upcoming_deprecation = Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS
string_args = {
pg_version_upcoming: upcoming_deprecation[:pg_version_minimum],
gl_version_upcoming: upcoming_deprecation[:gl_version],
gl_version_upcoming_date: upcoming_deprecation[:gl_version_date],
pg_version_upcoming_url_open: "<a href=\"#{upcoming_deprecation[:url]}\">".html_safe,
pg_version_upcoming_url_close: '</a>'.html_safe
}
notices <<
{
type: 'warning',
message: html_escape(_('Note that PostgreSQL %{pg_version_upcoming} will become the minimum required ' \
'version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please ' \
'consider upgrading your environment to a supported PostgreSQL version soon, ' \
'see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details.')) % string_args
}
end
notices
]
end
end
end
......
......@@ -6,20 +6,6 @@ module Gitlab
# https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements
MINIMUM_POSTGRES_VERSION = 11
# Upcoming PostgreSQL version requirements
# Allows a soft warning about an upcoming minimum version requirement
# so administrators can prepare to upgrade
UPCOMING_POSTGRES_VERSION_DETAILS = {
gl_version: '13.6.0',
gl_version_date: 'November 22, 2020',
pg_version_minimum: 12,
url: 'https://gitlab.com/groups/gitlab-org/-/epics/2374'
}.freeze
# Specifies the maximum number of days in advance to display a notice
# regarding an upcoming PostgreSQL version deprecation.
DEPRECATION_WINDOW_DAYS = 90
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
MAX_INT_VALUE = 2147483647
MIN_INT_VALUE = -2147483648
......@@ -114,22 +100,6 @@ module Gitlab
version.to_f >= MINIMUM_POSTGRES_VERSION
end
def self.postgresql_upcoming_deprecation?
version.to_f < UPCOMING_POSTGRES_VERSION_DETAILS[:pg_version_minimum]
end
def self.days_until_deprecation
(
Date.parse(UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) -
Date.today
).to_i
end
private_class_method :days_until_deprecation
def self.within_deprecation_notice_window?
days_until_deprecation <= DEPRECATION_WINDOW_DAYS
end
def self.check_postgres_version_and_print_warning
return if Gitlab::Database.postgresql_minimum_supported_version?
return if Gitlab::Runtime.rails_runner?
......
......@@ -16610,9 +16610,6 @@ msgstr ""
msgid "Note parameters are invalid: %{errors}"
msgstr ""
msgid "Note that PostgreSQL %{pg_version_upcoming} will become the minimum required version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please consider upgrading your environment to a supported PostgreSQL version soon, see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details."
msgstr ""
msgid "Note that this invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}."
msgstr ""
......@@ -27906,7 +27903,7 @@ msgstr ""
msgid "You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico."
msgstr ""
msgid "You are using PostgreSQL %{pg_version_current}, but PostgreSQL %{pg_version_minimum} is required for this version of GitLab. Please upgrade your environment to a supported PostgreSQL version, see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details."
msgid "You are using PostgreSQL %{pg_version_current}, but PostgreSQL %{pg_version_minimum} is required for this version of GitLab. Please upgrade your environment to a supported PostgreSQL version, see %{pg_requirements_url} for details."
msgstr ""
msgid "You can %{linkStart}view the blob%{linkEnd} instead."
......
......@@ -555,6 +555,21 @@ RSpec.describe GroupsController do
end
end
context 'when there is a conflicting group path' do
render_views
let!(:conflict_group) { create(:group, path: SecureRandom.hex(12) ) }
let!(:old_name) { group.name }
it 'does not render references to the conflicting group' do
put :update, params: { id: group.to_param, group: { path: conflict_group.path } }
expect(response).to have_gitlab_http_status(:ok)
expect(group.reload.name).to eq(old_name)
expect(response.body).not_to include(conflict_group.path)
end
end
context 'when a project inside the group has container repositories' do
before do
stub_container_registry_config(enabled: true)
......
......@@ -179,7 +179,7 @@ describe('Snippet Edit app', () => {
${'foo'} | ${[]} | ${false}
${'foo'} | ${[TEST_ACTIONS.VALID]} | ${false}
${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_CONTENT]} | ${true}
${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${true}
${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${false}
`(
'should handle submit disable (title=$title, actions=$actions, shouldDisable=$shouldDisable)',
async ({ title, actions, shouldDisable }) => {
......
......@@ -7,14 +7,21 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
describe '#resolve' do
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
let_it_be(:incident) { create(:incident, project: project, state: :closed, created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
# This issue should not be included in the counts
let_it_be(:other_project) { create(:project) }
let_it_be(:other_proj_issue) { create(:issue, state: :opened, project: other_project) }
let(:parent) { project }
let(:args) { {} }
before do
before_all do
project.add_developer(current_user)
other_project.add_developer(current_user)
end
subject { resolve_issue_status_counts(args) }
......@@ -22,12 +29,22 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
it { is_expected.to be_a(Gitlab::IssuablesCountForState) }
specify { expect(subject.project).to eq(project) }
it 'returns expected results' do
result = resolve_issue_status_counts
shared_examples 'returns expected results' do
it 'returns expected results', :aggregate_failures do
result = resolve_issue_status_counts
expect(result.all).to eq 2
expect(result.opened).to eq 1
expect(result.closed).to eq 1
expect(result.all).to eq 2
expect(result.opened).to eq 1
expect(result.closed).to eq 1
end
end
it_behaves_like 'returns expected results'
context 'group used as parent' do
let(:parent) { project.group }
it_behaves_like 'returns expected results'
end
it 'filters by search', :aggregate_failures do
......@@ -58,7 +75,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
private
def resolve_issue_status_counts(args = {}, context = { current_user: current_user })
resolve(described_class, obj: project, args: args, ctx: context)
resolve(described_class, obj: parent, args: args, ctx: context)
end
end
end
......@@ -55,7 +55,7 @@ RSpec.describe Backup::Repository do
end
[4, 10].each do |max_storage_concurrency|
context "max_storage_concurrency #{max_storage_concurrency}" do
context "max_storage_concurrency #{max_storage_concurrency}", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/241701' do
it 'creates the expected number of threads' do
expect(Thread).to receive(:new)
.exactly(storage_keys.length * (max_storage_concurrency + 1)).times
......
......@@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
describe '#check' do
subject { described_class.check }
let_it_be(:deprecation_warning) { "Please upgrade" }
let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" }
context 'when database meets minimum version and there is no upcoming deprecation' do
context 'when database meets minimum supported version' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end
it { is_expected.to be_empty }
end
context 'when database does not meet minimum version and there is no upcoming deprecation' do
context 'when database does not meet minimum supported version' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
end
end
context 'when database meets minimum version and there is an upcoming deprecation' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
let(:notice_deprecated_database) do
{
type: 'warning',
message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url} for details.') % {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
}
}
end
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
it 'only returns notice about an upcoming deprecation' do
is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(deprecation_warning)))
end
end
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it { is_expected.to be_empty }
end
end
context 'when database does not meet minimum version and there is an upcoming deprecation' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
end
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
it 'returns notice about deprecated database version and an upcoming deprecation' do
is_expected.to include(
a_hash_including(message: include(deprecation_warning)),
a_hash_including(message: include(upcoming_deprecation_warning))
)
end
end
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
end
it 'reports deprecated database notice' do
is_expected.to contain_exactly(notice_deprecated_database)
end
end
end
......
......@@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do
end
end
describe '.postgresql_upcoming_deprecation?' do
it 'returns true when database version is lower than the upcoming minimum' do
allow(described_class).to receive(:version).and_return('11')
expect(described_class.postgresql_upcoming_deprecation?).to eq(true)
end
it 'returns false when database version equals the upcoming minimum' do
allow(described_class).to receive(:version).and_return('12')
expect(described_class.postgresql_upcoming_deprecation?).to eq(false)
end
it 'returns false when database version is greater the upcoming minimum' do
allow(described_class).to receive(:version).and_return('13')
expect(described_class.postgresql_upcoming_deprecation?).to eq(false)
end
end
describe '.within_deprecation_notice_window?' do
using RSpec::Parameterized::TableSyntax
where(:case_name, :days, :result) do
'outside window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS + 1 | false
'equal to window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS | true
'within window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS - 1 | true
end
with_them do
it "returns #{params[:result]} when #{params[:case_name]}" do
allow(Date)
.to receive(:today)
.and_return Date.parse(Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) - days
expect(described_class.within_deprecation_notice_window?).to eq(result)
end
end
end
describe '.check_postgres_version_and_print_warning' do
subject { described_class.check_postgres_version_and_print_warning }
......
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