From 2f00709f337c76982dfe69cbc62dc3cb148131f2 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 19 Jun 2023 18:07:19 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- GITALY_SERVER_VERSION | 2 +- ...recate-sidekiq-delivery-method-for-mailroom.yml | 5 +- ..._add_detected_at_id_index_to_vulnerabilities.rb | 15 +++++ ...ect_id_state_id_index_to_vulnerability_reads.rb | 15 +++++ db/schema_migrations/20230601211635 | 1 + db/schema_migrations/20230601213750 | 1 + db/structure.sql | 4 ++ doc/api/graphql/reference/index.md | 1 + doc/topics/git/git_rebase.md | 3 +- doc/update/deprecations.md | 5 +- lib/gitlab/redis/multi_store.rb | 35 +++++----- lib/gitlab/slash_commands/presenters/access.rb | 4 +- spec/lib/gitlab/redis/multi_store_spec.rb | 75 +++++++++++++++------- .../slash_commands/presenters/access_spec.rb | 2 +- .../base_slash_commands_shared_examples.rb | 2 +- 15 files changed, 123 insertions(+), 47 deletions(-) create mode 100644 db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb create mode 100644 db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb create mode 100644 db/schema_migrations/20230601211635 create mode 100644 db/schema_migrations/20230601213750 diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index eaf8c0c6be1..829f41679b2 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -40d411cfea1d40ae2525268896ae75fe026c3e9e +d687ebe4b114fce6d74deed3d7f45c0b58e3bbc4 diff --git a/data/deprecations/16-0-deprecate-sidekiq-delivery-method-for-mailroom.yml b/data/deprecations/16-0-deprecate-sidekiq-delivery-method-for-mailroom.yml index a7715f89abb..d0795687b50 100644 --- a/data/deprecations/16-0-deprecate-sidekiq-delivery-method-for-mailroom.yml +++ b/data/deprecations/16-0-deprecate-sidekiq-delivery-method-for-mailroom.yml @@ -34,7 +34,10 @@ If you run GitLab on more than one machine, you need to provide the secret key file for each machine. - We highly encourage GitLab administrators to start using the `webhook` delivery method for + We encourage GitLab administrators to switch to the webhook delivery method for `incoming_email_delivery_method` and `service_desk_email_delivery_method` instead of `sidekiq`. + + [Issue 393157](https://gitlab.com/gitlab-org/gitlab/-/issues/393157) tracks improving email ingestion in general. + We hope this will simplify infrastructure setup and add several improvements to how you manage GitLab in the near future. tiers: [Free, Silver, Gold, Core, Premium, Ultimate] documentation_url: https://docs.gitlab.com/ee/user/project/service_desk.html#use-a-custom-email-address diff --git a/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb b/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb new file mode 100644 index 00000000000..e7ccfad1fd3 --- /dev/null +++ b/db/post_migrate/20230601211635_add_detected_at_id_index_to_vulnerabilities.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddDetectedAtIdIndexToVulnerabilities < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_vulnerabilities_on_detected_at_and_id' + + def up + add_concurrent_index :vulnerabilities, [:id, :detected_at], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME + end +end diff --git a/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb b/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb new file mode 100644 index 00000000000..f91394eb783 --- /dev/null +++ b/db/post_migrate/20230601213750_add_uuid_project_id_state_id_index_to_vulnerability_reads.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddUuidProjectIdStateIdIndexToVulnerabilityReads < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_vulnerability_reads_on_uuid_project_id_and_state' + + def up + add_concurrent_index :vulnerability_reads, [:uuid, :project_id, :state], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME + end +end diff --git a/db/schema_migrations/20230601211635 b/db/schema_migrations/20230601211635 new file mode 100644 index 00000000000..a92c327bce6 --- /dev/null +++ b/db/schema_migrations/20230601211635 @@ -0,0 +1 @@ +c987632b4c7628e5fef9d5c6c0876ae2af7a34db2bdd87df8560c82adbdb604f \ No newline at end of file diff --git a/db/schema_migrations/20230601213750 b/db/schema_migrations/20230601213750 new file mode 100644 index 00000000000..494b48356ca --- /dev/null +++ b/db/schema_migrations/20230601213750 @@ -0,0 +1 @@ +f3e1bffc9586ee332497c3b6a72f86a8678b171c8a3eb538df4c4a5147bec04b \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a1ca2147c8c..073fd5e31fa 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -33195,6 +33195,8 @@ CREATE INDEX index_vulnerabilities_on_author_id ON vulnerabilities USING btree ( CREATE INDEX index_vulnerabilities_on_confirmed_by_id ON vulnerabilities USING btree (confirmed_by_id); +CREATE INDEX index_vulnerabilities_on_detected_at_and_id ON vulnerabilities USING btree (id, detected_at); + CREATE INDEX index_vulnerabilities_on_dismissed_by_id ON vulnerabilities USING btree (dismissed_by_id); CREATE INDEX index_vulnerabilities_on_due_date_sourcing_milestone_id ON vulnerabilities USING btree (due_date_sourcing_milestone_id); @@ -33315,6 +33317,8 @@ CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USIN CREATE UNIQUE INDEX index_vulnerability_reads_on_uuid ON vulnerability_reads USING btree (uuid); +CREATE INDEX index_vulnerability_reads_on_uuid_project_id_and_state ON vulnerability_reads USING btree (uuid, project_id, state); + CREATE UNIQUE INDEX index_vulnerability_reads_on_vulnerability_id ON vulnerability_reads USING btree (vulnerability_id); CREATE UNIQUE INDEX index_vulnerability_remediations_on_project_id_and_checksum ON vulnerability_remediations USING btree (project_id, checksum); diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 95420764226..4412eb56c82 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -19846,6 +19846,7 @@ Represents a product analytics dashboard panel. | Name | Type | Description | | ---- | ---- | ----------- | | `gridAttributes` | [`JSON`](#json) | Description of the position and size of the panel. | +| `queryOverrides` | [`JSON`](#json) | Overrides for the visualization query object. | | `title` | [`String!`](#string) | Title of the panel. | | `visualization` | [`ProductAnalyticsDashboardVisualization!`](#productanalyticsdashboardvisualization) | Visualization of the panel. | diff --git a/doc/topics/git/git_rebase.md b/doc/topics/git/git_rebase.md index bc9337481d4..dd2260b04dc 100644 --- a/doc/topics/git/git_rebase.md +++ b/doc/topics/git/git_rebase.md @@ -44,10 +44,9 @@ branch, such as `release-15-3`. You can also specify a different remote reposito To back up a branch before taking any destructive action, like a rebase or force push: 1. Open your feature branch in the terminal: `git checkout my-feature` -1. Check out a new branch from it: `git checkout -b my-feature-backup` +1. Create a backup branch: `git branch my-feature-backup` Any changes added to `my-feature` after this point are lost if you restore from the backup branch. -1. Change back to your original branch: `git checkout my-feature` Your branch is backed up, and you can try a rebase or a force push. If anything goes wrong, restore your branch from its backup: diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md index ecf0f68de0e..8346269ec37 100644 --- a/doc/update/deprecations.md +++ b/doc/update/deprecations.md @@ -776,9 +776,12 @@ echo $( ruby -rsecurerandom -e "puts SecureRandom.base64(32)" ) > ~/.gitlab-mail If you run GitLab on more than one machine, you need to provide the secret key file for each machine. -We highly encourage GitLab administrators to start using the `webhook` delivery method for +We encourage GitLab administrators to switch to the webhook delivery method for `incoming_email_delivery_method` and `service_desk_email_delivery_method` instead of `sidekiq`. +[Issue 393157](https://gitlab.com/gitlab-org/gitlab/-/issues/393157) tracks improving email ingestion in general. +We hope this will simplify infrastructure setup and add several improvements to how you manage GitLab in the near future. +
diff --git a/lib/gitlab/redis/multi_store.rb b/lib/gitlab/redis/multi_store.rb index d36ef6b99ee..ab2260ebc98 100644 --- a/lib/gitlab/redis/multi_store.rb +++ b/lib/gitlab/redis/multi_store.rb @@ -6,15 +6,15 @@ module Gitlab include Gitlab::Utils::StrongMemoize class PipelinedDiffError < StandardError - def initialize(result_primary, result_secondary) - @result_primary = result_primary - @result_secondary = result_secondary + def initialize(non_default_store_result, default_store_result) + @non_default_store_result = non_default_store_result + @default_store_result = default_store_result end def message "Pipelined command executed on both stores successfully but results differ between them. " \ - "Result from the primary: #{@result_primary.inspect}. " \ - "Result from the secondary: #{@result_secondary.inspect}." + "Result from the non-default store: #{@non_default_store_result.inspect}. " \ + "Result from the default store: #{@default_store_result.inspect}." end end @@ -27,8 +27,8 @@ module Gitlab attr_reader :primary_store, :secondary_store, :instance_name FAILED_TO_READ_ERROR_MESSAGE = 'Failed to read from the redis default_store.' - FAILED_TO_WRITE_ERROR_MESSAGE = 'Failed to write to the redis primary_store.' - FAILED_TO_RUN_PIPELINE = 'Failed to execute pipeline on the redis primary_store.' + FAILED_TO_WRITE_ERROR_MESSAGE = 'Failed to write to the redis non_default_store.' + FAILED_TO_RUN_PIPELINE = 'Failed to execute pipeline on the redis non_default_store.' SKIP_LOG_METHOD_MISSING_FOR_COMMANDS = %i[info].freeze @@ -192,7 +192,7 @@ module Gitlab use_primary_store_as_default? ? primary_store : secondary_store end - def fallback_store + def non_default_store use_primary_store_as_default? ? secondary_store : primary_store end @@ -252,36 +252,39 @@ module Gitlab end def write_both(command_name, *args, **kwargs, &block) + result = send_command(default_store, command_name, *args, **kwargs, &block) + + # write to the non-default store only if write on default store is successful begin - send_command(primary_store, command_name, *args, **kwargs, &block) + send_command(non_default_store, command_name, *args, **kwargs, &block) rescue StandardError => e log_error(e, command_name, multi_store_error_message: FAILED_TO_WRITE_ERROR_MESSAGE) end - send_command(secondary_store, command_name, *args, **kwargs, &block) + result end # Run the entire pipeline on both stores. We assume that `&block` is idempotent. def pipelined_both(command_name, *args, **kwargs, &block) + result_default = send_command(default_store, command_name, *args, **kwargs, &block) + begin - result_primary = send_command(primary_store, command_name, *args, **kwargs, &block) + result_non_default = send_command(non_default_store, command_name, *args, **kwargs, &block) rescue StandardError => e log_error(e, command_name, multi_store_error_message: FAILED_TO_RUN_PIPELINE) end - result_secondary = send_command(secondary_store, command_name, *args, **kwargs, &block) - # Pipelined commands return an array with all results. If they differ, log an error - if result_primary && result_primary != result_secondary - error = PipelinedDiffError.new(result_primary, result_secondary) + if result_non_default && result_non_default != result_default + error = PipelinedDiffError.new(result_non_default, result_default) error.set_backtrace(Thread.current.backtrace[1..]) # Manually set backtrace, since the error is not `raise`d log_error(error, command_name) increment_pipelined_command_error_count(command_name) end - result_secondary + result_default end def same_redis_store? diff --git a/lib/gitlab/slash_commands/presenters/access.rb b/lib/gitlab/slash_commands/presenters/access.rb index c9c5c6da3bf..e098762f290 100644 --- a/lib/gitlab/slash_commands/presenters/access.rb +++ b/lib/gitlab/slash_commands/presenters/access.rb @@ -21,8 +21,8 @@ module Gitlab def deactivated ephemeral_response(text: <<~MESSAGE) - You are not allowed to perform the given chatops command since - your account has been deactivated by your administrator. + You are not allowed to perform the given ChatOps command. Most likely + your #{Gitlab.config.gitlab.url} account needs to be reactivated. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url} MESSAGE diff --git a/spec/lib/gitlab/redis/multi_store_spec.rb b/spec/lib/gitlab/redis/multi_store_spec.rb index 80d5915b819..05cc1569a40 100644 --- a/spec/lib/gitlab/redis/multi_store_spec.rb +++ b/spec/lib/gitlab/redis/multi_store_spec.rb @@ -269,8 +269,8 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do multi_store.default_store.flushdb end - it 'does not call the fallback store' do - expect(multi_store.fallback_store).not_to receive(name) + it 'does not call the non_default_store' do + expect(multi_store.non_default_store).not_to receive(name) end end @@ -574,21 +574,33 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do end end - context 'when executing on the primary instance is raising an exception' do + context 'when executing on the default instance is raising an exception' do before do - allow(primary_store).to receive(name).with(*expected_args).and_raise(StandardError) + allow(multi_store.default_store).to receive(name).with(*expected_args).and_raise(StandardError) allow(Gitlab::ErrorTracking).to receive(:log_exception) end - it 'logs the exception and execute on secondary instance', :aggregate_failures do + it 'raises error and does not execute on non default instance', :aggregate_failures do + expect(multi_store.non_default_store).not_to receive(name).with(*expected_args) + expect { subject }.to raise_error(StandardError) + end + end + + context 'when executing on the non default instance is raising an exception' do + before do + allow(multi_store.non_default_store).to receive(name).with(*expected_args).and_raise(StandardError) + allow(Gitlab::ErrorTracking).to receive(:log_exception) + end + + it 'logs the exception and execute on default instance', :aggregate_failures do expect(Gitlab::ErrorTracking).to receive(:log_exception).with(an_instance_of(StandardError), hash_including(:multi_store_error_message, command_name: name, instance_name: instance_name)) - expect(secondary_store).to receive(name).with(*expected_args).and_call_original + expect(multi_store.default_store).to receive(name).with(*expected_args).and_call_original subject end - include_examples 'verify that store contains values', :secondary_store + include_examples 'verify that store contains values', :default_store end context 'when the command is executed within pipelined block' do @@ -661,21 +673,33 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do include_examples 'verify that store contains values', :secondary_store end - context 'when executing on the primary instance is raising an exception' do + context 'when executing on the default instance is raising an exception' do before do - allow(primary_store).to receive(name).and_raise(StandardError) + allow(multi_store.default_store).to receive(name).and_raise(StandardError) + end + + it 'raises error and does not execute on non default instance', :aggregate_failures do + expect(multi_store.non_default_store).not_to receive(name) + + expect { subject }.to raise_error(StandardError) + end + end + + context 'when executing on the non default instance is raising an exception' do + before do + allow(multi_store.non_default_store).to receive(name).and_raise(StandardError) allow(Gitlab::ErrorTracking).to receive(:log_exception) end - it 'logs the exception and execute on secondary instance', :aggregate_failures do + it 'logs the exception and execute on default instance', :aggregate_failures do expect(Gitlab::ErrorTracking).to receive(:log_exception).with(an_instance_of(StandardError), hash_including(:multi_store_error_message, command_name: name)) - expect(secondary_store).to receive(name).and_call_original + expect(multi_store.default_store).to receive(name).and_call_original subject end - include_examples 'verify that store contains values', :secondary_store + include_examples 'verify that store contains values', :default_store end describe 'return values from a pipelined command' do @@ -708,15 +732,16 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do context 'when the value exists on both but differ' do before do - primary_store.set(key1, value1) - secondary_store.set(key1, value2) + multi_store.non_default_store.set(key1, value1) + multi_store.default_store.set(key1, value2) end it 'returns the value from the secondary store, logging an error' do expect(Gitlab::ErrorTracking).to receive(:log_exception).with( pipeline_diff_error_with_stacktrace( 'Pipelined command executed on both stores successfully but results differ between them. ' \ - "Result from the primary: [#{value1.inspect}]. Result from the secondary: [#{value2.inspect}]." + "Result from the non-default store: [#{value1.inspect}]. " \ + "Result from the default store: [#{value2.inspect}]." ), hash_including(command_name: name, instance_name: instance_name) ).and_call_original @@ -726,16 +751,16 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do end end - context 'when the value does not exist on the primary but it does on the secondary' do + context 'when the value does not exist on the non-default store but it does on the default' do before do - secondary_store.set(key1, value2) + multi_store.default_store.set(key1, value2) end it 'returns the value from the secondary store, logging an error' do expect(Gitlab::ErrorTracking).to receive(:log_exception).with( pipeline_diff_error_with_stacktrace( 'Pipelined command executed on both stores successfully but results differ between them. ' \ - "Result from the primary: [nil]. Result from the secondary: [#{value2.inspect}]." + "Result from the non-default store: [nil]. Result from the default store: [#{value2.inspect}]." ), hash_including(command_name: name, instance_name: instance_name) ) @@ -784,18 +809,24 @@ RSpec.describe Gitlab::Redis::MultiStore, feature_category: :redis do end context 'when either store is a an instance of ::Redis::Cluster' do + let(:pipeline) { double } + let(:client) { double } + before do - client = double allow(client).to receive(:instance_of?).with(::Redis::Cluster).and_return(true) - allow(primary_store).to receive(:_client).and_return(client) + allow(pipeline).to receive(:pipelined) + allow(multi_store.default_store).to receive(:_client).and_return(client) end it 'calls cross-slot pipeline within multistore' do if name == :pipelined # we intentionally exclude `.and_call_original` since primary_store/secondary_store # may not be running on a proper Redis Cluster. - expect(Gitlab::Redis::CrossSlot::Pipeline).to receive(:new).with(primary_store).exactly(:once) - expect(Gitlab::Redis::CrossSlot::Pipeline).not_to receive(:new).with(secondary_store) + expect(Gitlab::Redis::CrossSlot::Pipeline).to receive(:new) + .with(multi_store.default_store) + .exactly(:once) + .and_return(pipeline) + expect(Gitlab::Redis::CrossSlot::Pipeline).not_to receive(:new).with(multi_store.non_default_store) end subject diff --git a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb index 5d62e96971b..3af0ae03256 100644 --- a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb +++ b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Gitlab::SlashCommands::Presenters::Access do it { is_expected.to be_a(Hash) } it_behaves_like 'displays an error message' do - let(:error_message) { 'your account has been deactivated by your administrator' } + let(:error_message) { "your #{Gitlab.config.gitlab.url} account needs to be reactivated" } end end diff --git a/spec/support/shared_examples/models/integrations/base_slash_commands_shared_examples.rb b/spec/support/shared_examples/models/integrations/base_slash_commands_shared_examples.rb index 0cf109ce5c5..ff3cc1841b4 100644 --- a/spec/support/shared_examples/models/integrations/base_slash_commands_shared_examples.rb +++ b/spec/support/shared_examples/models/integrations/base_slash_commands_shared_examples.rb @@ -122,7 +122,7 @@ RSpec.shared_examples Integrations::BaseSlashCommands do end it_behaves_like 'blocks command execution' do - let(:error_message) { 'your account has been deactivated by your administrator' } + let(:error_message) { "your #{Gitlab.config.gitlab.url} account needs to be reactivated" } end end end -- cgit v1.2.3