Commit 3ebdb1e9 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 9498f56c ee0b4e88
<!-- Title suggestion: [Feature flag] Enable description of feature -->
## What
## Feature
Remove the `:feature_name` feature flag ...
This feature uses the `:feature_name` feature flag!
<!-- Short description of what the feature is about and link to relevant other issues. -->
- [Issue Name](ISSUE LINK)
## Owners
- Team: NAME_OF_TEAM
- Most appropriate slack channel to reach out to: `#g_TEAM_NAME`
- Best individual to reach out to: NAME
- PM: NAME
## Expectations
## Stakeholders
### What are we expecting to happen?
<!--
Are there any other stages or teams involved that need to be kept in the loop?
### What might happen if this goes wrong?
- Name of a PM
- The Support Team
- The Delivery Team
-->
### What can we monitor to detect problems with this?
## The Rollout Plan
<!-- Which dashboards from https://dashboards.gitlab.net are most relevant? Sentry errors reports can also be useful to review -->
<!-- Describe how the feature should be rolled out, and check the right boxes. You can check multiple if applicable -->
- [ ] Partial Rollout on GitLab.com with beta groups
- [ ] Rollout on GitLab.com for a certain period (How long)
- [ ] Percentage Rollout on GitLab.com - XX%
If it is possible to perform an incremental rollout, this should be preferred. Proposed increments are: `10%`, `50%`, `100%`. Proposed minimum time between increments is 15 minutes.
- [ ] Rollout Feature for everyone as soon as it's ready
## Beta groups/projects
<!-- Which dashboards from https://dashboards.gitlab.net are most relevant? Sentry errors reports can alse be useful to review -->
If applicable, any groups/projects that are happy to have this feature turned on early. Some organizations may wish to test big changes they are interested in with a small subset of users ahead of time for example.
**Beta Groups/Projects:**
<!-- If applicable, any groups/projects that are happy to have this feature turned on early. Some organizations may wish to test big changes they are interested in with a small subset of users ahead of time for example. -->
- `gitlab-org/gitlab` project
- `gitlab-org`/`gitlab-com` groups
- ...
## Roll Out Steps
## Expectations
### What are we expecting to happen?
<!-- Describe the expected outcome when rolling out this feature -->
### What might happen if this goes wrong?
<!-- Should the feature flag be turned off? Any MRs that need to be rolled back? Communication that needs to happen? What are some things you can think of that could go wrong - data loss or broken pages? -->
### What can we monitor to detect problems with this?
<!-- Which dashboards from https://dashboards.gitlab.net are most relevant? -->
## Rollout Timeline
<!-- Please check which steps are needed and remove those which don't apply -->
**Initial Rollout**
*Preperation Phase*
- [ ] Enable on staging (`/chatops run feature set feature_name true --staging`)
- [ ] Test on staging
- [ ] Ensure that documentation has been updated
- [ ] Enable on GitLab.com for individual groups/projects listed above and verify behaviour (`/chatops run feature set --project=gitlab-org/gitlab feature_name true`)
- [ ] If it is possible to perform an incremental rollout, this should be preferred. Proposed increments are: `10%`, `50%`, `100%`. Proposed minimum time between increments is 15 minutes.
- [ ] Ensure that documentation has been updated ([More info](https://docs.gitlab.com/ee/development/documentation/feature_flags.html#features-that-became-enabled-by-default))
- [ ] Coordinate a time to enable the flag with the SRE oncall and release managers
- In `#production` mention `@sre-oncall` and `@release-managers`. Once an SRE on call and Release Manager on call confirm, you can proceed with the rollout
- [ ] Announce on the issue an estimated time this will be enabled on GitLab.com. **Note**: Once a feature rollout has started, it is not necessary to inform `@sre-oncall`/`@release-managers` at each stage of the gradual rollout.
- In `#production` by pinging `@sre-oncall`
- In `#g_delivery` by pinging `@release-managers`
- [ ] Announce on the issue an estimated time this will be enabled on GitLab.com
*Partial Rollout Phase*
- [ ] Enable on GitLab.com for individual groups/projects listed above and verify behaviour (`/chatops run feature set --project=gitlab-org/gitlab feature_name true`)
- [ ] Verify behaviour (See Beta Groups) and add details with screenshots as a comment on this issue
**Global Availability** ([More Info](https://docs.gitlab.com/ee/development/feature_flags/controls.html#communicate-the-change))
*(Please Note that Beta,Alpha and General Availability (GA) are handled on a product level and not the feature-flag)*
<!-- The next checkboxes are probably only needed for high visibility and/or critical rollouts. Please refer to the official documentation linked above for more clarification -->
- [ ] Coordinate a time to enable the flag with `#production` and `#g_delivery` on slack.
- [ ] Announce on the issue an estimated time this will be enabled on GitLab.com
- [ ] Make the feature flag enabled by default i.e. Change `default_enabled` to `true`
- [ ] Enable on GitLab.com by running chatops command in `#production` (`/chatops run feature set feature_name true`)
- [ ] Cross post chatops Slack command to `#support_gitlab-com` ([more guidance when this is necessary in the dev docs](https://docs.gitlab.com/ee/development/feature_flags/controls.html#where-to-run-commands)) and in your team channel
- [ ] Announce on the issue that the flag has been enabled
- [ ] Remove feature flag and add changelog entry. Ensure that the feature flag definition YAML file has been removed in the **same MR** that is removing the feature flag from the code
- [ ] After the flag removal is deployed, [clean up the feature flag](https://docs.gitlab.com/ee/development/feature_flags/controls.html#cleaning-up) by running chatops command in `#production` channel
- [ ] Cross post chatops slack command to `#support_gitlab-com` ([more guidance when this is necessary in the dev docs](https://docs.gitlab.com/ee/development/feature_flags/controls.html#where-to-run-commands)) and in your team channel
**Cleanup**
This is an __important__ phase, that should be either done in the next Milestone or as soon as possible. For the cleanup phase, please follow our documentation on how to [clean up the feature flag](https://docs.gitlab.com/ee/development/feature_flags/controls.html#cleaning-up).
<!-- The checklist here is to keep track of it's status for stakeholders -->
- [ ] Announce on the issue that the flag has been enabled
- [ ] Remove `:feature_name` feature flag
- [ ] Remove all references to the feature flag from the codebase
- [ ] Remove the YAML definitions for the feature from the repository
- [ ] Create a Changelog Entry
- [ ] Clean up the feature flag from all environments by running this chatops command in `#production` channel `/chatops run feature delete some_feature`.
**Final Step**
- [ ] Close this rollout issue for the feature flag after the feature flag is removed from the codebase.
## Rollback Steps
......@@ -54,3 +127,4 @@ If applicable, any groups/projects that are happy to have this feature turned on
```
/label ~"feature flag"
/assign DRI
......@@ -161,7 +161,11 @@ export default {
>
<gl-link
v-if="hasDetails"
v-gl-tooltip="{ boundary, placement: 'bottom', customClass: 'gl-pointer-events-none' }"
v-gl-tooltip="{
boundary: 'viewport',
placement: 'bottom',
customClass: 'gl-pointer-events-none',
}"
:href="detailsPath"
:title="tooltipText"
:class="jobClasses"
......
......@@ -150,7 +150,11 @@ export default {
>
<gl-link
v-if="hasDetails"
v-gl-tooltip="{ boundary, placement: 'bottom', customClass: 'gl-pointer-events-none' }"
v-gl-tooltip="{
boundary: 'viewport',
placement: 'bottom',
customClass: 'gl-pointer-events-none',
}"
:href="detailsPath"
:title="tooltipText"
:class="jobClasses"
......
......@@ -135,6 +135,7 @@ class Note < ApplicationRecord
project: [:project_members, :namespace, { group: [:group_members] }])
end
scope :with_metadata, -> { includes(:system_note_metadata) }
scope :with_web_entity_associations, -> { preload(:project, :author, :noteable) }
scope :for_note_or_capitalized_note, ->(text) { where(note: [text, text.capitalize]) }
scope :like_note_or_capitalized_note, ->(text) { where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) }
......
......@@ -142,7 +142,7 @@ class Packages::Package < ApplicationRecord
end
def self.only_maven_packages_with_path(path, use_cte: false)
if use_cte && Feature.enabled?(:maven_metadata_by_path_with_optimization_fence)
if use_cte && Feature.enabled?(:maven_metadata_by_path_with_optimization_fence, default_enabled: :yaml)
# This is an optimization fence which assumes that looking up the Metadatum record by path (globally)
# and then filter down the packages (by project or by group and subgroups) will be cheaper than
# looking up all packages within a project or group and filter them by path.
......
......@@ -9,7 +9,8 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated
projects: :with_web_entity_associations,
issues: :with_web_entity_associations,
merge_requests: :with_web_entity_associations,
epics: :with_web_entity_associations
epics: :with_web_entity_associations,
notes: :with_web_entity_associations
}.freeze
SORT_ENABLED_SCOPES = %w(issues merge_requests).freeze
......
......@@ -6,8 +6,10 @@ module Ci
def execute
if trigger_from_token
set_application_context_from_trigger(trigger_from_token)
create_pipeline_from_trigger(trigger_from_token)
elsif job_from_token
set_application_context_from_job(job_from_token)
create_pipeline_from_job(job_from_token)
end
......@@ -87,5 +89,20 @@ module Ci
value: params.except(*PAYLOAD_VARIABLE_HIDDEN_PARAMS).to_json,
variable_type: :file }
end
def set_application_context_from_trigger(trigger)
Gitlab::ApplicationContext.push(
user: trigger.owner,
project: trigger.project
)
end
def set_application_context_from_job(job)
Gitlab::ApplicationContext.push(
user: job.user,
project: job.project,
runner: job.runner
)
end
end
end
---
title: Fix N+1 for searching notes (comments) scope
merge_request: 57460
author:
type: performance
---
title: Sort code quality degradations in MR Widget comparison reports
merge_request: 57258
author:
type: added
---
title: Optimize group level Maven package finder query
merge_request: 57692
author:
type: performance
---
title: Fix tooltip position in mini pipeline chart
merge_request: 57425
author:
type: fixed
......@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/325460
milestone: '13.11'
type: development
group: group::optimize
default_enabled: false
default_enabled: true
......@@ -70,6 +70,16 @@ RSpec.describe SearchController, type: :request do
it_behaves_like 'an efficient database result'
end
context 'for notes scope' do
let(:creation_traits) { [:on_commit] }
let(:object) { :note }
let(:creation_args) { { project: project } }
let(:params) { { search: '*', scope: 'notes' } }
let(:threshold) { 0 }
it_behaves_like 'an efficient database result'
end
end
end
end
......@@ -6,6 +6,7 @@ module Gitlab
class CodequalityReports
attr_reader :degradations, :error_message
SEVERITY_PRIORITIES = %w(blocker critical major minor info).map.with_index.to_h.freeze # { "blocker" => 0, "critical" => 1 ... }
CODECLIMATE_SCHEMA_PATH = Rails.root.join('app', 'validators', 'json_schemas', 'codeclimate.json').to_s
def initialize
......@@ -29,6 +30,12 @@ module Gitlab
@degradations.values
end
def sort_degradations!
@degradations = @degradations.sort_by do |_fingerprint, degradation|
SEVERITY_PRIORITIES[degradation.dig(:severity)]
end.to_h
end
private
def valid_degradation?(degradation)
......
......@@ -7,6 +7,11 @@ module Gitlab
def initialize(base_report, head_report)
@base_report = base_report
@head_report = head_report
unless not_found?
@base_report.sort_degradations!
@head_report.sort_degradations!
end
end
def success?
......
......@@ -95,4 +95,47 @@ FactoryBot.define do
}.with_indifferent_access
end
end
# TODO: Use this in all other specs and remove the previous numbered factories
# https://gitlab.com/gitlab-org/gitlab/-/issues/325886
factory :codequality_degradation, class: Hash do
skip_create
# Feel free to add in more configurable properties here
# as the need arises
fingerprint { SecureRandom.hex }
severity { "major" }
Gitlab::Ci::Reports::CodequalityReports::SEVERITY_PRIORITIES.keys.each do |s|
trait s.to_sym do
severity { s }
end
end
initialize_with do
{
"categories": [
"Complexity"
],
"check_name": "argument_count",
"content": {
"body": ""
},
"description": "Avoid parameter lists longer than 5 parameters. [12/5]",
"fingerprint": fingerprint,
"location": {
"path": "file_a.rb",
"lines": {
"begin": 10,
"end": 10
}
},
"other_locations": [],
"remediation_points": 900000,
"severity": severity,
"type": "issue",
"engine_name": "structure"
}.with_indifferent_access
end
end
end
......@@ -6,15 +6,17 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
let(:comparer) { described_class.new(base_report, head_report) }
let(:base_report) { Gitlab::Ci::Reports::CodequalityReports.new }
let(:head_report) { Gitlab::Ci::Reports::CodequalityReports.new }
let(:degradation_1) { build(:codequality_degradation_1) }
let(:degradation_2) { build(:codequality_degradation_2) }
let(:major_degradation) { build(:codequality_degradation, :major) }
let(:minor_degradation) { build(:codequality_degradation, :major) }
let(:critical_degradation) { build(:codequality_degradation, :critical) }
let(:blocker_degradation) { build(:codequality_degradation, :blocker) }
describe '#status' do
subject(:report_status) { comparer.status }
context 'when head report has an error' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns status failed' do
......@@ -50,7 +52,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when head report has an error' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns the number of new errors' do
......@@ -70,8 +72,8 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has an error and head has a different error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'counts the base report error as resolved' do
......@@ -81,7 +83,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors head has no errors' do
before do
base_report.add_degradation(degradation_1)
base_report.add_degradation(major_degradation)
end
it 'counts the base report errors as resolved' do
......@@ -91,8 +93,8 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head has the same error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_1)
base_report.add_degradation(major_degradation)
head_report.add_degradation(major_degradation)
end
it 'returns zero' do
......@@ -102,7 +104,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report does not have errors and head has errors' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns zero' do
......@@ -124,7 +126,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has an error' do
before do
base_report.add_degradation(degradation_1)
base_report.add_degradation(major_degradation)
end
it 'returns zero' do
......@@ -134,7 +136,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when head report has an error' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'includes the head report error in the count' do
......@@ -144,8 +146,8 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head report has errors' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'includes errors in the count' do
......@@ -155,9 +157,9 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head report has the same error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'includes errors in the count' do
......@@ -179,20 +181,28 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head has the same error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
end
it 'includes the base report errors' do
expect(existing_errors).to contain_exactly(degradation_1)
base_report.add_degradation(major_degradation)
base_report.add_degradation(critical_degradation)
base_report.add_degradation(blocker_degradation)
head_report.add_degradation(critical_degradation)
head_report.add_degradation(blocker_degradation)
head_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'includes the base report errors sorted by severity' do
expect(existing_errors).to eq([
blocker_degradation,
critical_degradation,
major_degradation
])
end
end
context 'when base report has errors and head has a different error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'returns an empty array' do
......@@ -202,7 +212,7 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report does not have errors and head has errors' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns an empty array' do
......@@ -224,19 +234,25 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head has more errors' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(critical_degradation)
head_report.add_degradation(minor_degradation)
head_report.add_degradation(blocker_degradation)
head_report.add_degradation(major_degradation)
end
it 'includes errors not found in the base report' do
expect(new_errors).to eq([degradation_2])
it 'includes errors not found in the base report sorted by severity' do
expect(new_errors).to eq([
blocker_degradation,
critical_degradation,
minor_degradation
])
end
end
context 'when base report has an error and head has no errors' do
before do
base_report.add_degradation(degradation_1)
base_report.add_degradation(major_degradation)
end
it 'returns an empty array' do
......@@ -246,11 +262,11 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report does not have errors and head has errors' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns the head report error' do
expect(new_errors).to eq([degradation_1])
expect(new_errors).to eq([major_degradation])
end
end
......@@ -268,9 +284,9 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report errors are still found in the head report' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
head_report.add_degradation(major_degradation)
head_report.add_degradation(minor_degradation)
end
it 'returns an empty array' do
......@@ -280,18 +296,25 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do
context 'when base report has errors and head has a different error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
base_report.add_degradation(major_degradation)
base_report.add_degradation(minor_degradation)
base_report.add_degradation(critical_degradation)
base_report.add_degradation(blocker_degradation)
head_report.add_degradation(major_degradation)
end
it 'returns the base report error' do
expect(resolved_errors).to eq([degradation_1])
it 'returns the base report errors not found in the head report, sorted by severity' do
expect(resolved_errors).to eq([
blocker_degradation,
critical_degradation,
minor_degradation
])
end
end
context 'when base report does not have errors and head has errors' do
before do
head_report.add_degradation(degradation_1)
head_report.add_degradation(major_degradation)
end
it 'returns an empty array' do
......
......@@ -77,4 +77,36 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReports do
end
end
end
describe '#sort_degradations!' do
let(:major) { build(:codequality_degradation, :major) }
let(:minor) { build(:codequality_degradation, :minor) }
let(:blocker) { build(:codequality_degradation, :blocker) }
let(:info) { build(:codequality_degradation, :info) }
let(:major_2) { build(:codequality_degradation, :major) }
let(:critical) { build(:codequality_degradation, :critical) }
let(:codequality_report) { described_class.new }
before do
codequality_report.add_degradation(major)
codequality_report.add_degradation(minor)
codequality_report.add_degradation(blocker)
codequality_report.add_degradation(major_2)
codequality_report.add_degradation(info)
codequality_report.add_degradation(critical)
codequality_report.sort_degradations!
end
it 'sorts degradations based on severity' do
expect(codequality_report.degradations.values).to eq([
blocker,
critical,
major,
major_2,
minor,
info
])
end
end
end
......@@ -126,6 +126,39 @@ RSpec.describe API::Triggers do
end
end
describe 'adding arguments to the application context' do
subject { subject_proc.call }
let(:expected_params) { { client_id: "user/#{user.id}", project: project.full_path } }
let(:subject_proc) { proc { post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' } } }
context 'when triggering a pipeline from a trigger token' do
it_behaves_like 'storing arguments in the application context'
it_behaves_like 'not executing any extra queries for the application context'
end
context 'when triggered from another running job' do
let!(:trigger) { }
let!(:trigger_request) { }
context 'when other job is triggered by a user' do
let(:trigger_token) { create(:ci_build, :running, project: project, user: user).token }
it_behaves_like 'storing arguments in the application context'
it_behaves_like 'not executing any extra queries for the application context'
end
context 'when other job is triggered by a runner' do
let(:trigger_token) { create(:ci_build, :running, project: project, runner: runner).token }
let(:runner) { create(:ci_runner) }
let(:expected_params) { { client_id: "runner/#{runner.id}", project: project.full_path } }
it_behaves_like 'storing arguments in the application context'
it_behaves_like 'not executing any extra queries for the application context', 1
end
end
end
context 'when is triggered by a pipeline hook' do
it 'does not create a new pipeline' do
expect do
......
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