Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-05-18 00:10:37 +00:00
parent cd8520845d
commit 5ee9033e9d
15 changed files with 162 additions and 36 deletions

View File

@ -115,9 +115,6 @@ module WikiActions
@error = response.message
render 'shared/wikis/edit'
end
rescue WikiPage::PageChangedError, WikiPage::PageRenameError => e
@error = e.message
render 'shared/wikis/edit'
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables

View File

@ -2,6 +2,8 @@
module WikiPages
class UpdateService < WikiPages::BaseService
UpdateError = Class.new(StandardError)
def execute(page)
# this class is not thread safe!
@old_slug = page.slug
@ -10,11 +12,15 @@ module WikiPages
execute_hooks(page)
ServiceResponse.success(payload: { page: page })
else
ServiceResponse.error(
message: _('Could not update wiki page'),
payload: { page: page }
)
raise UpdateError, s_('Could not update wiki page')
end
rescue UpdateError, WikiPage::PageChangedError, WikiPage::PageRenameError => e
page.update_attributes(@params) # rubocop:disable Rails/ActiveRecordAliases
ServiceResponse.error(
message: e.message,
payload: { page: page }
)
end
def usage_counter_action

View File

@ -16,7 +16,7 @@ module Database
INTERVAL_VARIANCE = 5.seconds.freeze
def perform
return unless Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops) && active_migration
return unless Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops, default_enabled: :yaml) && active_migration
with_exclusive_lease(active_migration.interval) do
# Now that we have the exclusive lease, reload migration in case another process has changed it.

View File

@ -0,0 +1,5 @@
---
title: Preserve user changes in the wiki editor if multiple people edit the page
merge_request: 61120
author:
type: fixed

View File

@ -0,0 +1,5 @@
---
title: Enable by default scheduled execution of batched background migrations
merge_request: 61316
author:
type: added

View File

@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326241
milestone: '13.11'
type: ops
group: group::database
default_enabled: false
default_enabled: true

View File

@ -29,3 +29,4 @@ relevant compliance standards.
|**Separation of Duties using [Protected branches](../user/project/protected_branches.md#protected-branches-approval-by-code-owners) and [custom CI Configuration Paths](../ci/pipelines/settings.md#custom-cicd-configuration-path)**<br> GitLab Premium users can leverage the GitLab cross-project YAML configurations to define deployers of code and developers of code. View the [Separation of Duties Deploy Project](https://gitlab.com/guided-explorations/separation-of-duties-deploy/blob/master/README.md) and [Separation of Duties Project](https://gitlab.com/guided-explorations/separation-of-duties/blob/master/README.md) to see how to use this set up to define these roles.|Premium+|✓|Project|
|**[Compliance frameworks](../user/project/settings/index.md#compliance-frameworks)**<br>Create a custom compliance framework at the group level to describe the type of compliance requirements any child project needs to follow. |Premium+|✓|Group|
|**[Compliance pipelines](../user/project/settings/index.md#compliance-pipeline-configuration)**<br>Define a pipeline configuration to run for any projects with a given compliance framework.|Ultimate|✓|Group|
|**[Compliance dashboard](../user/compliance/compliance_dashboard/index.md)**<br>Quickly get visibility into the compliance posture of your organization.|Ultimate|✓|Group|

View File

@ -107,6 +107,10 @@ Sidekiq::Queue.new("background_migration").size
Sidekiq::ScheduledSet.new.select { |r| r.klass == 'BackgroundMigrationWorker' }.size
```
### Batched background migrations
See the documentation on [batched background migrations](../user/admin_area/monitoring/background_migrations.md).
### What do I do if my background migrations are stuck?
WARNING:

View File

@ -0,0 +1,48 @@
---
stage: Enablement
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
---
# Batched Background Migrations **(FREE SELF)**
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51332) in GitLab 13.11.
> - [Deployed behind a feature flag](../../../user/feature_flags.md), disabled by default.
> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/329511) in GitLab 13.12.
> - Enabled on GitLab.com.
> - Recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-batched-background-migrations). **(FREE SELF)**
There can be [risks when disabling released features](../../../user/feature_flags.md#risks-when-disabling-released-features).
Refer to this feature's version history for more details.
To update database tables in batches, GitLab can use batched background migrations. These migrations
are created by GitLab developers and run automatically on upgrade. However, such migrations are
limited in scope to help with migrating some `integer` database columns to `bigint`. This is needed to
prevent integer overflow for some tables.
All migrations must be finished before upgrading GitLab. To check the status of the existing
migrations, execute this command:
```ruby
Gitlab::Database::BackgroundMigration::BatchedMigration.pluck(:id, :table_name, :status)
```
## Enable or disable Batched Background Migrations **(FREE SELF)**
Batched Background Migrations is under development but ready for production use.
It is 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.
To enable it:
```ruby
Feature.enable(:execute_batched_migrations_on_schedule)
```
To disable it:
```ruby
Feature.disable(:execute_batched_migrations_on_schedule)
```

View File

@ -226,6 +226,10 @@ detected, add the following to `.gitattributes` in the root of your repository.
*.proto linguist-detectable=true
```
Sometimes this feature can use excessive CPU.
[Read about troubleshooting this](#repository-languages-excessive-cpu-use)
and also more about customizing this feature using `.gitattributes`.
## Locked files **(PREMIUM)**
Use [File Locking](../file_lock.md) to
@ -310,14 +314,40 @@ When [renaming a user](../../profile/index.md#change-your-username),
- The redirects are available as long as the original path is not claimed by
another group, user or project.
<!-- ## Troubleshooting
## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
### Repository Languages: excessive CPU use
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
GitLab uses a Ruby gem to scan all the files in the repository to determine what languages are used.
[Sometimes this can use excessive CPU](https://gitlab.com/gitlab-org/gitaly/-/issues/1565) if
a file type needs to be parsed by the gem to determine what sort of file it is.
The gem contains a [heuristics configuration file](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.yml)
that defines what file extensions need to be parsed.
Excessive CPU use has been reported for files with the extension `.txt` and XML files with
a file extension that is not defined by the gem.
The workaround is to specify what language to assign to specific file extensions.
The same approach should also allow misidentified file types to be fixed.
1. Identify which language to specify. The gem contains a [configuration file for known data types](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml).
The entry for `Text` files, for example:
```yaml
Text:
type: prose
wrap: true
aliases:
- fundamental
- plain text
extensions:
- ".txt"
```
1. Add or modify `.gitattributes` in the root of your repository:
```plaintext
*.txt linguist-language=Text
```
`*.txt` files have an entry in the heuristics file. The example above prevents parsing of these files.

View File

@ -19,6 +19,7 @@ module Gitlab
def initialize(stage:, params: {})
@stage = stage
@params = build_finder_params(params)
@params[:state] = :opened if in_progress?
end
# rubocop: disable CodeReuse/ActiveRecord

View File

@ -51,9 +51,9 @@
"@babel/preset-env": "^7.10.1",
"@gitlab/at.js": "1.5.7",
"@gitlab/favicon-overlay": "2.0.0",
"@gitlab/svgs": "1.196.0",
"@gitlab/svgs": "1.197.0",
"@gitlab/tributejs": "1.0.0",
"@gitlab/ui": "29.25.0",
"@gitlab/ui": "29.27.0",
"@gitlab/visual-review-tools": "1.6.1",
"@rails/actioncable": "^6.0.3-4",
"@rails/ujs": "^6.0.3-4",

View File

@ -62,4 +62,29 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::BaseQueryBuilder do
expect(records.size).to eq(2)
end
describe 'in progress filter' do
let_it_be(:mr3) { create(:merge_request, :opened, target_project: project, source_project: project, allow_broken: true, created_at: 3.months.ago) }
let_it_be(:mr4) { create(:merge_request, :closed, target_project: project, source_project: project, allow_broken: true, created_at: 1.month.ago) }
before do
params[:from] = 5.months.ago
end
context 'when the filter is present' do
before do
params[:end_event_filter] = :in_progress
end
it 'returns only open items' do
expect(records).to eq([mr3])
end
end
context 'when the filter is absent' do
it 'returns finished items' do
expect(records).to match_array([mr1, mr2])
end
end
end
end

View File

@ -117,14 +117,6 @@ RSpec.shared_examples 'User updates wiki page' do
expect(page).to have_selector('.atwho-view')
end
it 'shows the error message', :js do
wiki_page.update(content: 'Update') # rubocop:disable Rails/SaveBang
click_button('Save changes')
expect(page).to have_content('Someone edited the page the same time you did.')
end
it 'updates a page', :js do
fill_in('Content', with: 'Updated Wiki Content')
click_on('Save changes')
@ -145,6 +137,18 @@ RSpec.shared_examples 'User updates wiki page' do
end
it_behaves_like 'wiki file attachments'
context 'when multiple people edit the page at the same time' do
it 'preserves user changes in the wiki editor', :js do
wiki_page.update(content: 'Some Other Updates') # rubocop:disable Rails/SaveBang
fill_in('Content', with: 'Updated Wiki Content')
click_on('Save changes')
expect(page).to have_content('Someone edited the page the same time you did.')
expect(find('textarea#wiki_content').value).to eq('Updated Wiki Content')
end
end
end
context 'when the page is in a subdir', :js do

View File

@ -898,20 +898,20 @@
stylelint-declaration-strict-value "1.7.7"
stylelint-scss "3.18.0"
"@gitlab/svgs@1.196.0":
version "1.196.0"
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.196.0.tgz#7905bc66ef9c69ba7b5225326c0eaf4e55d11386"
integrity sha512-X/UGCBXIZXBcPqfRy8qaxQG/SYyrZajAazORZjmnVF+cyM9lQTuCiZFi7dHtMQ1XLew+m1NREVngCmBLuuK98g==
"@gitlab/svgs@1.197.0":
version "1.197.0"
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.197.0.tgz#70be3217b4c0c84b494615d0672734f40e3695d4"
integrity sha512-fW9EY3D1adWu4bGqo+74uElQ+U7qIxUM/I2np3133AZBeWK8bvW+92/SHpGQeINxcS/DBVOoepUSSUVvQEqroQ==
"@gitlab/tributejs@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8"
integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw==
"@gitlab/ui@29.25.0":
version "29.25.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-29.25.0.tgz#535f1e358176fb73d0e7df0315a8f50f7c8fc20b"
integrity sha512-Bt9wBj954Ev6UGbAJ0+ViT7ggOBXocyxru8NPDq060G7OAchtm6IQK0bwa4DugF5LxiP9IWXy34Oz55zjymwqw==
"@gitlab/ui@29.27.0":
version "29.27.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-29.27.0.tgz#c5cbe1fee2164705ea6a431c85f6fdaa2ff7e166"
integrity sha512-VoiYrozWyE9l/ddX308vsu+wQqaJJN3csngIlrJit3DzVZV9Z/OVWU/X9CWV8m/ubyr5ysEMqnrtnsQClR9FiA==
dependencies:
"@babel/standalone" "^7.0.0"
"@gitlab/vue-toasted" "^1.3.0"