Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-12 03:10:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-12 03:10:37 +0300
commitd9e285a74bf01b1a61108a8091a88579361ef189 (patch)
tree2f574a2af4fb59ab26c431f6de6aeeb83d4c4f08
parent63fd08e6b429cd3af81cf63dfc0e5fc853d04086 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/components/security_report_download_dropdown.vue6
-rw-r--r--app/assets/javascripts/vue_shared/security_reports/utils.js2
-rw-r--r--app/models/integration.rb2
-rw-r--r--app/models/namespaces/traversal/linear.rb4
-rw-r--r--app/models/project.rb4
-rw-r--r--doc/ci/runners/build_cloud/macos/environment.md2
-rw-r--r--doc/ci/runners/build_cloud/macos_build_cloud.md6
-rw-r--r--doc/update/index.md18
-rw-r--r--lib/gitlab/background_migration.rb21
-rw-r--r--lib/gitlab/ci/templates/Ruby.gitlab-ci.yml3
-rw-r--r--locale/gitlab.pot3
-rw-r--r--spec/lib/gitlab/background_migration_spec.rb66
-rw-r--r--spec/models/project_spec.rb54
13 files changed, 116 insertions, 75 deletions
diff --git a/app/assets/javascripts/vue_shared/security_reports/components/security_report_download_dropdown.vue b/app/assets/javascripts/vue_shared/security_reports/components/security_report_download_dropdown.vue
index 4178c5d1170..28618cb96a3 100644
--- a/app/assets/javascripts/vue_shared/security_reports/components/security_report_download_dropdown.vue
+++ b/app/assets/javascripts/vue_shared/security_reports/components/security_report_download_dropdown.vue
@@ -32,6 +32,11 @@ export default {
default: '',
},
},
+ computed: {
+ showDropdown() {
+ return this.loading || this.artifacts.length > 0;
+ },
+ },
methods: {
artifactText({ name }) {
return sprintf(s__('SecurityReports|Download %{artifactName}'), {
@@ -44,6 +49,7 @@ export default {
<template>
<gl-dropdown
+ v-if="showDropdown"
v-gl-tooltip
:text="text"
:title="title"
diff --git a/app/assets/javascripts/vue_shared/security_reports/utils.js b/app/assets/javascripts/vue_shared/security_reports/utils.js
index c3f24a7e52f..0add91c402e 100644
--- a/app/assets/javascripts/vue_shared/security_reports/utils.js
+++ b/app/assets/javascripts/vue_shared/security_reports/utils.js
@@ -14,7 +14,7 @@ const addReportTypeIfExists = (acc, reportTypes, reportType, getName, downloadPa
}
};
-const extractSecurityReportArtifacts = (reportTypes, jobs) => {
+export const extractSecurityReportArtifacts = (reportTypes, jobs) => {
return jobs.reduce((acc, job) => {
const artifacts = job.artifacts?.nodes ?? [];
diff --git a/app/models/integration.rb b/app/models/integration.rb
index 5c4d03f1fa8..a9c865569d0 100644
--- a/app/models/integration.rb
+++ b/app/models/integration.rb
@@ -274,7 +274,7 @@ class Integration < ApplicationRecord
end
def self.closest_group_integration(type, scope)
- group_ids = scope.ancestors.select(:id)
+ group_ids = scope.ancestors(hierarchy_order: :asc).select(:id)
array = group_ids.to_sql.present? ? "array(#{group_ids.to_sql})" : 'ARRAY[]'
where(type: type, group_id: group_ids, inherit_from_id: nil)
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb
index 081e51c1028..3216ec42427 100644
--- a/app/models/namespaces/traversal/linear.rb
+++ b/app/models/namespaces/traversal/linear.rb
@@ -178,6 +178,10 @@ module Namespaces
depth_sql = "ABS(#{traversal_ids.count} - array_length(traversal_ids, 1))"
skope = skope.select(skope.arel_table[Arel.star], "#{depth_sql} as depth")
.order(depth: hierarchy_order)
+ # The SELECT includes an extra depth attribute. We then wrap the SQL
+ # in a standard SELECT to avoid mismatched attribute errors when
+ # trying to chain future ActiveRelation commands.
+ skope = self.class.without_sti_condition.from(skope, self.class.table_name)
end
skope
diff --git a/app/models/project.rb b/app/models/project.rb
index 85bb1dea48f..9f90cef9c12 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -914,7 +914,9 @@ class Project < ApplicationRecord
.base_and_ancestors(upto: top, hierarchy_order: hierarchy_order)
end
- alias_method :ancestors, :ancestors_upto
+ def ancestors(hierarchy_order: nil)
+ namespace&.self_and_ancestors(hierarchy_order: hierarchy_order)
+ end
def ancestors_upto_ids(...)
ancestors_upto(...).pluck(:id)
diff --git a/doc/ci/runners/build_cloud/macos/environment.md b/doc/ci/runners/build_cloud/macos/environment.md
index 72fe641f50d..e84b7d0a207 100644
--- a/doc/ci/runners/build_cloud/macos/environment.md
+++ b/doc/ci/runners/build_cloud/macos/environment.md
@@ -14,7 +14,7 @@ When you use the Build Cloud for macOS:
## VM types
The virtual machine where your job runs has `sudo` access with no password.
-For the beta, there is only one available machine type, `gbc-macos-large`.
+For the Beta, there is only one available machine type, `gbc-macos-large`.
| Instance type | vCPUS | Memory (GB) |
| --------- | --- | ------- |
diff --git a/doc/ci/runners/build_cloud/macos_build_cloud.md b/doc/ci/runners/build_cloud/macos_build_cloud.md
index fdd4de7a540..1400c7e08db 100644
--- a/doc/ci/runners/build_cloud/macos_build_cloud.md
+++ b/doc/ci/runners/build_cloud/macos_build_cloud.md
@@ -6,8 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Build Cloud runners for macOS (Beta)
-Build Cloud for macOS Beta provides on-demand GitLab Runners integrated with GitLab SaaS [CI/CD](../../../ci/index.md)
-to build, test, and deploy apps for the Apple ecosystem (macOS, iOS, tvOS). You can take advantage
+The GitLab Build Cloud for macOS Beta provides on-demand runners integrated with GitLab SaaS [CI/CD](../../../ci/index.md).
+Use these runners to build, test, and deploy apps for the Apple ecosystem (macOS, iOS, tvOS). You can take advantage
of all the capabilities of the GitLab single DevOps platform and not have to manage or operate a
build environment.
@@ -59,4 +59,4 @@ test:
```
NOTE:
-During the beta period, the architecture of this solution will change. Rather than the jobs running on a specific VM instance, they will run on an ephemeral VM instance that is created by an autoscaling instance, known as the Runner Manager. We will notify all beta participants of any downtime required to do this work.
+During the Beta period, the architecture of this solution will change. Rather than the jobs running on a specific VM instance, they will run on an ephemeral VM instance that is created by an autoscaling instance, known as the Runner Manager. We will notify all Beta participants of any downtime required to do this work.
diff --git a/doc/update/index.md b/doc/update/index.md
index ed057782bf9..1289614c181 100644
--- a/doc/update/index.md
+++ b/doc/update/index.md
@@ -86,35 +86,19 @@ To check the status of [batched background migrations](../user/admin_area/monito
**For Omnibus installations**
-If using GitLab 12.9 and newer, also run:
+You can also run:
```shell
sudo gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
```
-If using GitLab 12.8 and older, run the following using a [Rails console](../administration/operations/rails_console.md#starting-a-rails-console-session):
-
-```ruby
-puts Sidekiq::Queue.new("background_migration").size
-Sidekiq::ScheduledSet.new.select { |r| r.klass == 'BackgroundMigrationWorker' }.size
-```
-
**For installations from source**
-If using GitLab 12.9 and newer, run:
-
```shell
cd /home/git/gitlab
sudo -u git -H bundle exec rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
```
-If using GitLab 12.8 and older, run the following using a [Rails console](../administration/operations/rails_console.md#starting-a-rails-console-session):
-
-```ruby
-Sidekiq::Queue.new("background_migration").size
-Sidekiq::ScheduledSet.new.select { |r| r.klass == 'BackgroundMigrationWorker' }.size
-```
-
### What do I do if my background migrations are stuck?
WARNING:
diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb
index 9f4d6557023..0826887dd0a 100644
--- a/lib/gitlab/background_migration.rb
+++ b/lib/gitlab/background_migration.rb
@@ -31,7 +31,7 @@ module Gitlab
queue.each do |job|
migration_class, migration_args = job.args
- next unless job.queue == self.queue
+ next unless job.klass == 'BackgroundMigrationWorker'
next unless migration_class == steal_class
next if block_given? && !(yield job)
@@ -60,11 +60,14 @@ module Gitlab
end
def self.remaining
- scheduled = Sidekiq::ScheduledSet.new.count do |job|
- job.queue == self.queue
- end
+ enqueued = Sidekiq::Queue.new(self.queue)
+ scheduled = Sidekiq::ScheduledSet.new
- scheduled + Sidekiq::Queue.new(self.queue).size
+ [enqueued, scheduled].sum do |set|
+ set.count do |job|
+ job.klass == 'BackgroundMigrationWorker'
+ end
+ end
end
def self.exists?(migration_class, additional_queues = [])
@@ -105,13 +108,11 @@ module Gitlab
end
def self.enqueued_job?(queues, migration_class)
- queues.each do |queue|
- queue.each do |job|
- return true if job.queue == self.queue && job.args.first == migration_class
+ queues.any? do |queue|
+ queue.any? do |job|
+ job.klass == 'BackgroundMigrationWorker' && job.args.first == migration_class
end
end
-
- false
end
end
end
diff --git a/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml b/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml
index 490fc779e17..0c8b98dc1cf 100644
--- a/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml
@@ -29,7 +29,8 @@ before_script:
- ruby -v # Print out ruby version for debugging
# Uncomment next line if your rails app needs a JS runtime:
# - apt-get update -q && apt-get install nodejs -yqq
- - bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
+ - bundle config set path 'vendor' # Install dependencies into ./vendor/ruby
+ - bundle install -j $(nproc)
# Optional - Delete if not using `rubocop`
rubocop:
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 683f4331dbe..030d9600ee5 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -29594,9 +29594,6 @@ msgstr ""
msgid "SecurityReports|Configure security testing"
msgstr ""
-msgid "SecurityReports|Coverage fuzzing"
-msgstr ""
-
msgid "SecurityReports|Create Jira issue"
msgstr ""
diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb
index 5b20572578c..f32e6891716 100644
--- a/spec/lib/gitlab/background_migration_spec.rb
+++ b/spec/lib/gitlab/background_migration_spec.rb
@@ -13,7 +13,11 @@ RSpec.describe Gitlab::BackgroundMigration do
describe '.steal' do
context 'when there are enqueued jobs present' do
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ [
+ double(args: ['Foo', [10, 20]], klass: 'BackgroundMigrationWorker'),
+ double(args: ['Bar', [20, 30]], klass: 'BackgroundMigrationWorker'),
+ double(args: ['Foo', [20, 30]], klass: 'MergeWorker')
+ ]
end
before do
@@ -45,7 +49,7 @@ RSpec.describe Gitlab::BackgroundMigration do
expect(queue[0]).not_to receive(:delete)
- described_class.steal('Bar')
+ described_class.steal('Baz')
end
context 'when a custom predicate is given' do
@@ -72,8 +76,8 @@ RSpec.describe Gitlab::BackgroundMigration do
let(:migration) { spy(:migration) }
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue),
- double(args: ['Foo', [20, 30]], queue: described_class.queue)]
+ [double(args: ['Foo', [10, 20]], klass: 'BackgroundMigrationWorker'),
+ double(args: ['Foo', [20, 30]], klass: 'BackgroundMigrationWorker')]
end
before do
@@ -128,11 +132,11 @@ RSpec.describe Gitlab::BackgroundMigration do
context 'when retry_dead_jobs is true', :redis do
let(:retry_queue) do
- [double(args: ['Object', [3]], queue: described_class.queue, delete: true)]
+ [double(args: ['Object', [3]], klass: 'BackgroundMigrationWorker', delete: true)]
end
let(:dead_queue) do
- [double(args: ['Object', [4]], queue: described_class.queue, delete: true)]
+ [double(args: ['Object', [4]], klass: 'BackgroundMigrationWorker', delete: true)]
end
before do
@@ -187,20 +191,22 @@ RSpec.describe Gitlab::BackgroundMigration do
describe '.remaining', :redis do
context 'when there are jobs remaining' do
- let(:queue) { Array.new(12) }
-
before do
- allow(Sidekiq::Queue).to receive(:new)
- .with(described_class.queue)
- .and_return(Array.new(12))
-
Sidekiq::Testing.disable! do
- BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
+ MergeWorker.perform_async('Foo')
+ MergeWorker.perform_in(10.minutes, 'Foo')
+
+ 5.times do
+ BackgroundMigrationWorker.perform_async('Foo')
+ end
+ 3.times do
+ BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
+ end
end
end
it 'returns the enqueued jobs plus the scheduled jobs' do
- expect(described_class.remaining).to eq(13)
+ expect(described_class.remaining).to eq(8)
end
end
@@ -211,16 +217,13 @@ RSpec.describe Gitlab::BackgroundMigration do
end
end
- describe '.exists?' do
+ describe '.exists?', :redis do
context 'when there are enqueued jobs present' do
- let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
- end
-
before do
- allow(Sidekiq::Queue).to receive(:new)
- .with(described_class.queue)
- .and_return(queue)
+ Sidekiq::Testing.disable! do
+ MergeWorker.perform_async('Bar')
+ BackgroundMigrationWorker.perform_async('Foo')
+ end
end
it 'returns true if specific job exists' do
@@ -232,19 +235,14 @@ RSpec.describe Gitlab::BackgroundMigration do
end
end
- context 'when there are scheduled jobs present', :redis do
+ context 'when there are scheduled jobs present' do
before do
Sidekiq::Testing.disable! do
+ MergeWorker.perform_in(10.minutes, 'Bar')
BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
-
- expect(Sidekiq::ScheduledSet.new).to be_one
end
end
- after do
- Sidekiq::ScheduledSet.new.clear
- end
-
it 'returns true if specific job exists' do
expect(described_class.exists?('Foo')).to eq(true)
end
@@ -257,7 +255,10 @@ RSpec.describe Gitlab::BackgroundMigration do
describe '.dead_jobs?' do
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ [
+ double(args: ['Foo', [10, 20]], klass: 'BackgroundMigrationWorker'),
+ double(args: ['Bar'], klass: 'MergeWorker')
+ ]
end
context 'when there are dead jobs present' do
@@ -277,7 +278,10 @@ RSpec.describe Gitlab::BackgroundMigration do
describe '.retrying_jobs?' do
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ [
+ double(args: ['Foo', [10, 20]], klass: 'BackgroundMigrationWorker'),
+ double(args: ['Bar'], klass: 'MergeWorker')
+ ]
end
context 'when there are dead jobs present' do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 7e1673a5299..5b045814891 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe Project, factory_default: :keep do
include ProjectForksHelper
include GitHelpers
include ExternalAuthorizationServiceHelpers
+ include ReloadHelpers
using RSpec::Parameterized::TableSyntax
let_it_be(:namespace) { create_default(:namespace).freeze }
@@ -3021,31 +3022,72 @@ RSpec.describe Project, factory_default: :keep do
end
end
- describe '#ancestors_upto' do
+ shared_context 'project with ancestors' do
let_it_be(:parent) { create(:group) }
let_it_be(:child) { create(:group, parent: parent) }
let_it_be(:child2) { create(:group, parent: child) }
let_it_be(:project) { create(:project, namespace: child2) }
+ end
- it 'returns all ancestors when no namespace is given' do
- expect(project.ancestors_upto).to contain_exactly(child2, child, parent)
+ shared_examples '#ancestors' do
+ before do
+ reload_models(parent, child, child2)
end
- it 'includes ancestors upto but excluding the given ancestor' do
- expect(project.ancestors_upto(parent)).to contain_exactly(child2, child)
+ it 'returns all ancestors' do
+ expect(project.ancestors).to contain_exactly(child2, child, parent)
end
describe 'with hierarchy_order' do
it 'returns ancestors ordered by descending hierarchy' do
- expect(project.ancestors_upto(hierarchy_order: :desc)).to eq([parent, child, child2])
+ expect(project.ancestors(hierarchy_order: :desc).to_a).to eq([parent, child, child2])
end
+ end
+ end
+
+ describe '#ancestors' do
+ include_context 'project with ancestors'
+
+ include_examples '#ancestors'
+ end
+
+ describe '#ancestors_upto' do
+ include_context 'project with ancestors'
+
+ include_examples '#ancestors'
+
+ it 'includes ancestors upto but excluding the given ancestor' do
+ expect(project.ancestors_upto(parent)).to contain_exactly(child2, child)
+ end
+ describe 'with hierarchy_order' do
it 'can be used with upto option' do
expect(project.ancestors_upto(parent, hierarchy_order: :desc)).to eq([child, child2])
end
end
end
+ describe '#ancestors' do
+ let_it_be(:parent) { create(:group) }
+ let_it_be(:child) { create(:group, parent: parent) }
+ let_it_be(:child2) { create(:group, parent: child) }
+ let_it_be(:project) { create(:project, namespace: child2) }
+
+ before do
+ reload_models(parent, child, child2)
+ end
+
+ it 'returns all ancestors' do
+ expect(project.ancestors).to contain_exactly(child2, child, parent)
+ end
+
+ describe 'with hierarchy_order' do
+ it 'returns ancestors ordered by descending hierarchy' do
+ expect(project.ancestors(hierarchy_order: :desc).to_a).to eq([parent, child, child2])
+ end
+ end
+ end
+
describe '#root_ancestor' do
let(:project) { create(:project) }