From aaedbff77d0e656e9738322a59476bbb2fab8266 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 22 Sep 2022 21:10:24 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../get_issue_participants.query.graphql | 4 ++-- .../queries/get_mr_participants.query.graphql | 4 ++-- .../components/user_select/user_select.vue | 1 + app/services/projects/destroy_service.rb | 2 +- .../development/extract_mr_diff_deletions.yml | 8 -------- ...dd_reject_non_dco_commits_to_push_rules.rb | 7 +++++++ ...or_vulnerability_reads_container_images.rb | 19 +++++++++++++++++++ db/schema_migrations/20220914112457 | 1 + db/schema_migrations/20220915192521 | 1 + db/structure.sql | 3 ++- doc/user/packages/pypi_repository/index.md | 2 +- lib/gitlab/query_limiting/transaction.rb | 19 +++++++++++++------ .../settings/user_transfers_a_project_spec.rb | 2 +- .../gitlab/query_limiting/transaction_spec.rb | 12 ++++++------ spec/requests/api/internal/base_spec.rb | 2 +- .../services/projects/destroy_service_spec.rb | 14 -------------- spec/support/helpers/graphql_helpers.rb | 2 +- .../api/issuable_update_shared_examples.rb | 2 +- 18 files changed, 60 insertions(+), 45 deletions(-) delete mode 100644 config/feature_flags/development/extract_mr_diff_deletions.yml create mode 100644 db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb create mode 100644 db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb create mode 100644 db/schema_migrations/20220914112457 create mode 100644 db/schema_migrations/20220915192521 diff --git a/app/assets/javascripts/vue_shared/components/sidebar/queries/get_issue_participants.query.graphql b/app/assets/javascripts/vue_shared/components/sidebar/queries/get_issue_participants.query.graphql index 445817d3e52..eae5e96ac46 100644 --- a/app/assets/javascripts/vue_shared/components/sidebar/queries/get_issue_participants.query.graphql +++ b/app/assets/javascripts/vue_shared/components/sidebar/queries/get_issue_participants.query.graphql @@ -1,7 +1,7 @@ #import "~/graphql_shared/fragments/user.fragment.graphql" #import "~/graphql_shared/fragments/user_availability.fragment.graphql" -query issueParticipants($fullPath: ID!, $iid: String!) { +query issueParticipants($fullPath: ID!, $iid: String!, $getStatus: Boolean = false) { workspace: project(fullPath: $fullPath) { id issuable: issue(iid: $iid) { @@ -9,7 +9,7 @@ query issueParticipants($fullPath: ID!, $iid: String!) { participants { nodes { ...User - ...UserAvailability + ...UserAvailability @include(if: $getStatus) } } } diff --git a/app/assets/javascripts/vue_shared/components/sidebar/queries/get_mr_participants.query.graphql b/app/assets/javascripts/vue_shared/components/sidebar/queries/get_mr_participants.query.graphql index 3496d5f4a2e..2781ac71f31 100644 --- a/app/assets/javascripts/vue_shared/components/sidebar/queries/get_mr_participants.query.graphql +++ b/app/assets/javascripts/vue_shared/components/sidebar/queries/get_mr_participants.query.graphql @@ -1,7 +1,7 @@ #import "~/graphql_shared/fragments/user.fragment.graphql" #import "~/graphql_shared/fragments/user_availability.fragment.graphql" -query getMrParticipants($fullPath: ID!, $iid: String!) { +query getMrParticipants($fullPath: ID!, $iid: String!, $getStatus: Boolean = false) { workspace: project(fullPath: $fullPath) { id issuable: mergeRequest(iid: $iid) { @@ -9,7 +9,7 @@ query getMrParticipants($fullPath: ID!, $iid: String!) { participants { nodes { ...User - ...UserAvailability + ...UserAvailability @include(if: $getStatus) } } } diff --git a/app/assets/javascripts/vue_shared/components/user_select/user_select.vue b/app/assets/javascripts/vue_shared/components/user_select/user_select.vue index 3180bd0d283..86a99b8f0ed 100644 --- a/app/assets/javascripts/vue_shared/components/user_select/user_select.vue +++ b/app/assets/javascripts/vue_shared/components/user_select/user_select.vue @@ -103,6 +103,7 @@ export default { return { iid: this.iid, fullPath: this.fullPath, + getStatus: true, }; }, update(data) { diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index f1525ed9763..4e883f682fb 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -134,7 +134,7 @@ module Projects destroy_ci_records! destroy_mr_diff_relations! - destroy_merge_request_diffs! if ::Feature.enabled?(:extract_mr_diff_deletions) + destroy_merge_request_diffs! # Rails attempts to load all related records into memory before # destroying: https://github.com/rails/rails/issues/22510 diff --git a/config/feature_flags/development/extract_mr_diff_deletions.yml b/config/feature_flags/development/extract_mr_diff_deletions.yml deleted file mode 100644 index 24067f95074..00000000000 --- a/config/feature_flags/development/extract_mr_diff_deletions.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: extract_mr_diff_deletions -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/96455 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/372060 -milestone: '15.4' -type: development -group: group::source code -default_enabled: false diff --git a/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb b/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb new file mode 100644 index 00000000000..57b3c209660 --- /dev/null +++ b/db/migrate/20220914112457_add_reject_non_dco_commits_to_push_rules.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddRejectNonDcoCommitsToPushRules < Gitlab::Database::Migration[2.0] + def change + add_column :push_rules, :reject_non_dco_commits, :boolean + end +end diff --git a/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb b/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb new file mode 100644 index 00000000000..18ed1b2cd2b --- /dev/null +++ b/db/post_migrate/20220915192521_prepare_async_trigram_index_for_vulnerability_reads_container_images.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class PrepareAsyncTrigramIndexForVulnerabilityReadsContainerImages < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_vulnerability_reads_on_location_image_trigram' + REPORT_TYPES = { container_scanning: 2, cluster_image_scanning: 7 }.freeze + + def up + prepare_async_index :vulnerability_reads, :location_image, + name: INDEX_NAME, + using: :gin, opclass: { location_image: :gin_trgm_ops }, + where: "report_type = ANY (ARRAY[#{REPORT_TYPES.values.join(', ')}]) AND location_image IS NOT NULL" + end + + def down + unprepare_async_index :vulnerability_reads, :location_image, name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20220914112457 b/db/schema_migrations/20220914112457 new file mode 100644 index 00000000000..ab67d0abb99 --- /dev/null +++ b/db/schema_migrations/20220914112457 @@ -0,0 +1 @@ +766866e84cdafce6506f18e574e1cfb760a581fa7464ce7e29c31d9778c687c0 \ No newline at end of file diff --git a/db/schema_migrations/20220915192521 b/db/schema_migrations/20220915192521 new file mode 100644 index 00000000000..ce848d0f186 --- /dev/null +++ b/db/schema_migrations/20220915192521 @@ -0,0 +1 @@ +9686a948e67f25d64f66187db27699b838b2caef11f27884dd6e868e4bcf7d47 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 2756c8fa8ff..c26af7af0da 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -20511,7 +20511,8 @@ CREATE TABLE push_rules ( reject_unsigned_commits boolean, commit_committer_check boolean, regexp_uses_re2 boolean DEFAULT true, - commit_message_negative_regex character varying + commit_message_negative_regex character varying, + reject_non_dco_commits boolean ); CREATE SEQUENCE push_rules_id_seq diff --git a/doc/user/packages/pypi_repository/index.md b/doc/user/packages/pypi_repository/index.md index 45e4a60fd83..fb1b9ce78ab 100644 --- a/doc/user/packages/pypi_repository/index.md +++ b/doc/user/packages/pypi_repository/index.md @@ -426,7 +426,7 @@ the three characters, such as `my-package`, `my_package`, and `my....package`. ## Troubleshooting -To improve performance, PyPI caches files related to a package. Note that PyPI doesn't remove data by +To improve performance, the pip command caches files related to a package. Note that pip doesn't remove data by itself. The cache grows as new packages are installed. If you encounter issues, clear the cache with this command: diff --git a/lib/gitlab/query_limiting/transaction.rb b/lib/gitlab/query_limiting/transaction.rb index 2e31849caaa..46c0a0ddf7a 100644 --- a/lib/gitlab/query_limiting/transaction.rb +++ b/lib/gitlab/query_limiting/transaction.rb @@ -14,8 +14,13 @@ module Gitlab # The maximum number of SQL queries that can be executed in a request. For # the sake of keeping things simple we hardcode this value here, it's not # supposed to be changed very often anyway. - THRESHOLD = 100 - LOG_THRESHOLD = THRESHOLD * 1.5 + def self.threshold + 100 + end + + def self.log_threshold + threshold * 1.5 + end # Error that is raised whenever exceeding the maximum number of queries. ThresholdExceededError = Class.new(StandardError) @@ -76,7 +81,7 @@ module Gitlab end def executed_sql(sql) - return if @count > LOG_THRESHOLD || ignorable?(sql) + return if @count > self.class.log_threshold || ignorable?(sql) @sql_executed << sql end @@ -86,15 +91,15 @@ module Gitlab end def threshold_exceeded? - count > THRESHOLD + count > self.class.threshold end def error_message header = 'Too many SQL queries were executed' header = "#{header} in #{action}" if action - msg = "a maximum of #{THRESHOLD} is allowed but #{count} SQL queries were executed" + msg = "a maximum of #{self.class.threshold} is allowed but #{count} SQL queries were executed" log = @sql_executed.each_with_index.map { |sql, i| "#{i}: #{sql}" }.join("\n").presence - ellipsis = '...' if @count > LOG_THRESHOLD + ellipsis = '...' if @count > self.class.log_threshold ["#{header}: #{msg}", log, ellipsis].compact.join("\n") end @@ -105,3 +110,5 @@ module Gitlab end end end + +Gitlab::QueryLimiting::Transaction.prepend_mod diff --git a/spec/features/projects/settings/user_transfers_a_project_spec.rb b/spec/features/projects/settings/user_transfers_a_project_spec.rb index 6041dca305b..23e10a36cee 100644 --- a/spec/features/projects/settings/user_transfers_a_project_spec.rb +++ b/spec/features/projects/settings/user_transfers_a_project_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Projects > Settings > User transfers a project', :js do let(:group) { create(:group) } before do - stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 120) + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(120) group.add_owner(user) sign_in(user) diff --git a/spec/lib/gitlab/query_limiting/transaction_spec.rb b/spec/lib/gitlab/query_limiting/transaction_spec.rb index 27da1f23556..d8eb2040ccc 100644 --- a/spec/lib/gitlab/query_limiting/transaction_spec.rb +++ b/spec/lib/gitlab/query_limiting/transaction_spec.rb @@ -52,7 +52,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do context 'when the query threshold is exceeded' do let(:transaction) do trans = described_class.new - trans.count = described_class::THRESHOLD + 1 + trans.count = described_class.threshold + 1 trans end @@ -120,7 +120,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do it 'returns true when the threshold is exceeded' do transaction = described_class.new - transaction.count = described_class::THRESHOLD + 1 + transaction.count = described_class.threshold + 1 expect(transaction.threshold_exceeded?).to eq(true) end @@ -129,7 +129,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do describe '#error_message' do it 'returns the error message to display when the threshold is exceeded' do transaction = described_class.new - transaction.count = max = described_class::THRESHOLD + transaction.count = max = described_class.threshold expect(transaction.error_message).to eq( "Too many SQL queries were executed: a maximum of #{max} " \ @@ -139,7 +139,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do it 'includes a list of executed queries' do transaction = described_class.new - transaction.count = max = described_class::THRESHOLD + transaction.count = max = described_class.threshold %w[foo bar baz].each { |sql| transaction.executed_sql(sql) } message = transaction.error_message @@ -154,7 +154,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do it 'indicates if the log is truncated' do transaction = described_class.new - transaction.count = described_class::THRESHOLD * 2 + transaction.count = described_class.threshold * 2 message = transaction.error_message @@ -163,7 +163,7 @@ RSpec.describe Gitlab::QueryLimiting::Transaction do it 'includes the action name in the error message when present' do transaction = described_class.new - transaction.count = max = described_class::THRESHOLD + transaction.count = max = described_class.threshold transaction.action = 'UsersController#show' expect(transaction.error_message).to eq( diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 1f6c241b3f5..4173a854421 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -1033,7 +1033,7 @@ RSpec.describe API::Internal::Base do context 'git push' do before do - stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 120) + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(120) end subject { push_with_path(key, full_path: path, changes: '_any') } diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 8269dbebccb..f7f02769f6a 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -146,20 +146,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi expect { destroy_project(project, user, {}) }.to change(MergeRequestDiff, :count).by(-1) expect { another_project_mr.reload }.not_to raise_error end - - context 'when extract_mr_diff_deletions feature flag is disabled' do - before do - stub_feature_flags(extract_mr_diff_deletions: false) - end - - it 'also deletes merge request diffs' do - merge_request_diffs = merge_request.merge_request_diffs - expect(merge_request_diffs.size).to eq(1) - - expect { destroy_project(project, user, {}) }.to change(MergeRequestDiff, :count).by(-1) - expect { another_project_mr.reload }.not_to raise_error - end - end end it_behaves_like 'deleting the project' diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 9d745f2cb70..cf87ee697b6 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -717,7 +717,7 @@ module GraphqlHelpers end def allow_high_graphql_transaction_threshold - stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 1000) + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(1000) end def allow_high_graphql_query_size diff --git a/spec/support/shared_examples/requests/api/issuable_update_shared_examples.rb b/spec/support/shared_examples/requests/api/issuable_update_shared_examples.rb index a3378d4619b..1045a92f332 100644 --- a/spec/support/shared_examples/requests/api/issuable_update_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/issuable_update_shared_examples.rb @@ -20,7 +20,7 @@ RSpec.shared_examples 'issuable update endpoint' do end it 'updates the issuable with labels param as array' do - stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 110) + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(110) params = { labels: ['label1', 'label2', 'foo, bar', '&,?'] }