Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-01-04 15:15:09 +00:00
parent 76893705a1
commit d19a19ce85
15 changed files with 167 additions and 78 deletions

View File

@ -4,9 +4,6 @@ GraphQL/OrderedArguments:
- app/graphql/resolvers/base_issues_resolver.rb
- app/graphql/resolvers/design_management/designs_resolver.rb
- app/graphql/resolvers/design_management/version/design_at_version_resolver.rb
- app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb
- app/graphql/resolvers/design_management/version_in_collection_resolver.rb
- app/graphql/resolvers/group_milestones_resolver.rb
- app/graphql/resolvers/merge_requests_resolver.rb
- app/graphql/resolvers/paginated_tree_resolver.rb
- app/graphql/resolvers/tree_resolver.rb

View File

@ -1 +1 @@
1.49.0
1.50.0

View File

@ -47,6 +47,9 @@ export default {
}
},
},
safeHtmlConfig: {
ADD_TAGS: ['copy-code'],
},
};
</script>
@ -62,7 +65,11 @@ export default {
</div>
<div class="blob-viewer" data-qa-selector="blob_viewer_content" itemprop="about">
<gl-loading-icon v-if="loading > 0" size="md" color="dark" class="my-4 mx-auto" />
<div v-else-if="readme" ref="readme" v-safe-html="readme.html"></div>
<div
v-else-if="readme"
ref="readme"
v-safe-html:[$options.safeHtmlConfig]="readme.html"
></div>
</div>
</article>
</template>

View File

@ -13,13 +13,13 @@ module Resolvers
DesignID = ::Types::GlobalIDType[::DesignManagement::Design]
argument :ids, [DesignID],
required: false,
description: 'Filters designs by their ID.'
argument :filenames,
[GraphQL::Types::String],
required: false,
description: 'Filters designs by their filename.'
argument :ids, [DesignID],
required: false,
description: 'Filters designs by their ID.'
def self.single
::Resolvers::DesignManagement::Version::DesignAtVersionResolver

View File

@ -15,13 +15,13 @@ module Resolvers
VersionID = ::Types::GlobalIDType[::DesignManagement::Version]
argument :sha, GraphQL::Types::String,
required: false,
description: "SHA256 of a specific version."
argument :id, VersionID,
as: :version_id,
required: false,
description: 'Global ID of the version.'
argument :sha, GraphQL::Types::String,
required: false,
description: "SHA256 of a specific version."
def resolve(version_id: nil, sha: nil)
# TODO: remove this line when the compatibility layer is removed

View File

@ -2,12 +2,12 @@
module Resolvers
class GroupMilestonesResolver < MilestonesResolver
argument :include_descendants, GraphQL::Types::Boolean,
required: false,
description: 'Include milestones from all subgroups and subprojects.'
argument :include_ancestors, GraphQL::Types::Boolean,
required: false,
description: 'Include milestones from all parent groups.'
argument :include_descendants, GraphQL::Types::Boolean,
required: false,
description: 'Include milestones from all subgroups and subprojects.'
type Types::MilestoneType.connection_type, null: true

View File

@ -1021,7 +1021,15 @@ module Ci
transaction do
update_columns(status: :failed, failure_reason: :data_integrity_failure)
all_queuing_entries.delete_all
all_runtime_metadata.delete_all
end
Gitlab::AppLogger.info(
message: 'Build doomed',
class: self.class.name,
build_id: id,
pipeline_id: pipeline_id,
project_id: project_id)
end
def degradation_threshold
@ -1067,6 +1075,10 @@ module Ci
::Ci::PendingBuild.upsert_from_build!(self)
end
def create_runtime_metadata!
::Ci::RunningBuild.upsert_shared_runner_build!(self)
end
##
# We can have only one queuing entry or running build tracking entry,
# because there is a unique index on `build_id` in each table, but we need

View File

@ -34,7 +34,7 @@ module Ci
# rubocop: enable CodeReuse/ActiveRecord
def drop_build(type, build, reason)
Gitlab::AppLogger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{build.status}, failure_reason: #{reason})"
log_dropping_message(type, build, reason)
Gitlab::OptimisticLocking.retry_lock(build, 3, name: 'stuck_ci_jobs_worker_drop_build') do |b|
b.drop(reason)
end
@ -53,6 +53,16 @@ module Ci
project_id: build.project_id
)
end
def log_dropping_message(type, build, reason)
Gitlab::AppLogger.info(class: self.class.name,
message: "Dropping #{type} build",
build_stuck_type: type,
build_id: build.id,
runner_id: build.runner_id,
build_status: build.status,
build_failure_reason: reason)
end
end
end
end

View File

@ -6,11 +6,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Audit event streaming **(ULTIMATE)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332747) in GitLab 14.5 [with a flag](../administration/feature_flags.md) named `ff_external_audit_events_namespace`. Disabled by default.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332747) in GitLab 14.5 [with a flag](../administration/feature_flags.md) named `ff_external_audit_events_namespace`. Disabled by default.
> - [Enabled on GitLab.com and self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/338939) in GitLab 14.7.
FLAG:
On self-managed GitLab, by default this feature is not available. To make it available per group, ask an administrator to [enable the feature flag](../administration/feature_flags.md) named `ff_external_audit_events_namespace`. On GitLab.com, this feature is not available.
You should not use this feature for production environments.
On self-managed GitLab, by default this feature is available. To hide the feature per group, ask an administrator to [disable the feature flag](../administration/feature_flags.md) named `ff_external_audit_events_namespace`. On GitLab.com, this feature is available.
Event streaming allows owners of top-level groups to set an HTTP endpoint to receive **all** audit events about the group, and its
subgroups and projects.

View File

@ -512,6 +512,7 @@ instance and project.
| Change project configuration | | | ✓ | ✓ |
| Add specific runners | | | ✓ | ✓ |
| Add shared runners | | | | ✓ |
| Clear runner caches manually | | | ✓ | ✓ |
| See events in the system | | | | ✓ |
| Admin Area | | | | ✓ |

View File

@ -200,9 +200,7 @@ module Gitlab
end
def sidekiq_exporter_enabled?
::Settings.monitoring.sidekiq_exporter.enabled
rescue Settingslogic::MissingSetting
nil
::Settings.dig('monitoring', 'sidekiq_exporter', 'enabled')
end
def exporter_has_a_unique_port?
@ -216,15 +214,11 @@ module Gitlab
end
def sidekiq_exporter_port
::Settings.monitoring.sidekiq_exporter.port
rescue Settingslogic::MissingSetting
nil
::Settings.dig('monitoring', 'sidekiq_exporter', 'port')
end
def sidekiq_health_check_port
::Settings.monitoring.sidekiq_health_checks.port
rescue Settingslogic::MissingSetting
nil
::Settings.dig('monitoring', 'sidekiq_health_checks', 'port')
end
def metrics_server_enabled?

View File

@ -5,7 +5,7 @@ require 'rspec-parameterized'
require_relative '../../../sidekiq_cluster/cli'
RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
RSpec.describe Gitlab::SidekiqCluster::CLI, stubbing_settings_source: true do # rubocop:disable RSpec/FilePath
let(:cli) { described_class.new('/dev/null') }
let(:timeout) { Gitlab::SidekiqCluster::DEFAULT_SOFT_TIMEOUT_SECONDS }
let(:default_options) do
@ -16,19 +16,39 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
let(:sidekiq_exporter_port) { '3807' }
let(:sidekiq_health_checks_port) { '3807' }
before do
stub_env('RAILS_ENV', 'test')
stub_config(
monitoring: {
sidekiq_exporter: {
enabled: sidekiq_exporter_enabled,
port: sidekiq_exporter_port
},
sidekiq_health_checks: {
port: sidekiq_health_checks_port
let(:config_file) { Tempfile.new('gitlab.yml') }
let(:config) do
{
'test' => {
'monitoring' => {
'sidekiq_exporter' => {
'address' => 'localhost',
'enabled' => sidekiq_exporter_enabled,
'port' => sidekiq_exporter_port
},
'sidekiq_health_checks' => {
'address' => 'localhost',
'enabled' => sidekiq_exporter_enabled,
'port' => sidekiq_health_checks_port
}
}
}
)
}
end
before do
stub_env('RAILS_ENV', 'test')
config_file.write(YAML.dump(config))
config_file.close
allow(::Settings).to receive(:source).and_return(config_file.path)
::Settings.reload!
end
after do
config_file.unlink
end
describe '#run' do
@ -272,16 +292,9 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
context 'starting the server' do
context 'without --dryrun' do
context 'when there are no sidekiq_health_checks settings set' do
before do
stub_config(
monitoring: {
sidekiq_exporter: {
enabled: true,
port: sidekiq_exporter_port
}
}
)
let(:sidekiq_exporter_enabled) { true }
before do
allow(Gitlab::SidekiqCluster).to receive(:start)
allow(cli).to receive(:write_pid)
allow(cli).to receive(:trap_signals)
@ -293,25 +306,12 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
cli.run(%w(foo))
end
it 'rescues Settingslogic::MissingSetting' do
expect { cli.run(%w(foo)) }.not_to raise_error(Settingslogic::MissingSetting)
end
end
context 'when the sidekiq_exporter.port setting is not set' do
before do
stub_config(
monitoring: {
sidekiq_exporter: {
enabled: true
},
sidekiq_health_checks: {
port: sidekiq_health_checks_port
}
}
)
let(:sidekiq_exporter_enabled) { true }
before do
allow(Gitlab::SidekiqCluster).to receive(:start)
allow(cli).to receive(:write_pid)
allow(cli).to receive(:trap_signals)
@ -323,23 +323,25 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
cli.run(%w(foo))
end
it 'rescues Settingslogic::MissingSetting' do
expect { cli.run(%w(foo)) }.not_to raise_error(Settingslogic::MissingSetting)
end
end
context 'when sidekiq_exporter.enabled setting is not set' do
before do
stub_config(
monitoring: {
sidekiq_exporter: {},
sidekiq_health_checks: {
port: sidekiq_health_checks_port
let(:config) do
{
'test' => {
'monitoring' => {
'sidekiq_exporter' => {},
'sidekiq_health_checks' => {
'address' => 'localhost',
'enabled' => sidekiq_exporter_enabled,
'port' => sidekiq_health_checks_port
}
}
}
)
}
end
before do
allow(Gitlab::SidekiqCluster).to receive(:start)
allow(cli).to receive(:write_pid)
allow(cli).to receive(:trap_signals)
@ -353,6 +355,36 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do # rubocop:disable RSpec/FilePath
end
end
context 'with a blank sidekiq_exporter setting' do
let(:config) do
{
'test' => {
'monitoring' => {
'sidekiq_exporter' => nil,
'sidekiq_health_checks' => nil
}
}
}
end
before do
allow(Gitlab::SidekiqCluster).to receive(:start)
allow(cli).to receive(:write_pid)
allow(cli).to receive(:trap_signals)
allow(cli).to receive(:start_loop)
end
it 'does not start a sidekiq metrics server' do
expect(MetricsServer).not_to receive(:spawn)
cli.run(%w(foo))
end
it 'does not throw an error' do
expect { cli.run(%w(foo)) }.not_to raise_error
end
end
context 'with valid settings' do
using RSpec::Parameterized::TableSyntax

View File

@ -335,6 +335,10 @@ FactoryBot.define do
running
runner factory: :ci_runner
after(:create) do |build|
build.create_runtime_metadata!
end
end
trait :artifacts do

View File

@ -5427,7 +5427,8 @@ RSpec.describe Ci::Build do
describe '#doom!' do
subject { build.doom! }
let_it_be(:build) { create(:ci_build, :queued) }
let(:traits) { [] }
let(:build) { create(:ci_build, *traits, pipeline: pipeline) }
it 'updates status and failure_reason', :aggregate_failures do
subject
@ -5436,10 +5437,33 @@ RSpec.describe Ci::Build do
expect(build.failure_reason).to eq("data_integrity_failure")
end
it 'drops associated pending build' do
subject
it 'logs a message' do
expect(Gitlab::AppLogger)
.to receive(:info)
.with(a_hash_including(message: 'Build doomed', class: build.class.name, build_id: build.id))
.and_call_original
expect(build.reload.queuing_entry).not_to be_present
subject
end
context 'with queued builds' do
let(:traits) { [:queued] }
it 'drops associated pending build' do
subject
expect(build.reload.queuing_entry).not_to be_present
end
end
context 'with running builds' do
let(:traits) { [:picked] }
it 'drops associated runtime metadata' do
subject
expect(build.reload.runtime_metadata).not_to be_present
end
end
end

View File

@ -463,6 +463,14 @@ RSpec.configure do |config|
$stdout = STDOUT
end
config.around(:each, stubbing_settings_source: true) do |example|
original_instance = ::Settings.instance_variable_get(:@instance)
example.run
::Settings.instance_variable_set(:@instance, original_instance)
end
config.disable_monkey_patching!
end