diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-18 06:10:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-18 06:10:38 +0300 |
commit | f24e50f0a55e872a2947ccb1af166b14883511b2 (patch) | |
tree | 0db04f6f1b893439887ee21b18a0ea027b5f62e6 | |
parent | 5ee9033e9db11ce04f5cc6d7bda32f8059a1f405 (diff) |
Add latest changes from gitlab-org/gitlab@master
21 files changed, 202 insertions, 90 deletions
diff --git a/app/assets/javascripts/boards/graphql/issue.fragment.graphql b/app/assets/javascripts/boards/graphql/issue.fragment.graphql index 7ecf9261214..47ecb55c72b 100644 --- a/app/assets/javascripts/boards/graphql/issue.fragment.graphql +++ b/app/assets/javascripts/boards/graphql/issue.fragment.graphql @@ -13,7 +13,6 @@ fragment IssueNode on Issue { emailsDisabled confidential webUrl - subscribed relativePosition milestone { id diff --git a/app/assets/javascripts/vue_shared/alert_details/components/alert_sidebar.vue b/app/assets/javascripts/vue_shared/alert_details/components/alert_sidebar.vue index 1c9791bba78..ca42cb0b1b5 100644 --- a/app/assets/javascripts/vue_shared/alert_details/components/alert_sidebar.vue +++ b/app/assets/javascripts/vue_shared/alert_details/components/alert_sidebar.vue @@ -65,6 +65,8 @@ export default { :project-path="projectPath" :alert="alert" :sidebar-collapsed="sidebarStatus" + text-class="gl-text-gray-500" + class="gl-w-70p" @toggle-sidebar="$emit('toggle-sidebar')" @alert-error="$emit('alert-error', $event)" /> diff --git a/app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue b/app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue index 35e2518b989..8715eb99518 100644 --- a/app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue +++ b/app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue @@ -34,6 +34,11 @@ export default { type: Boolean, required: false, }, + textClass: { + type: String, + required: false, + default: '', + }, }, data() { return { @@ -57,8 +62,11 @@ export default { dropdown.show(); } }, - handleUpdating(updating) { - this.isUpdating = updating; + handleUpdating(isMutationInProgress) { + if (!isMutationInProgress) { + this.$emit('alert-update'); + } + this.isUpdating = isMutationInProgress; }, }, }; @@ -66,7 +74,7 @@ export default { <template> <div - class="alert-status gl-py-5 gl-w-70p" + class="alert-status gl-py-5" :class="{ 'gl-border-b-1 gl-border-b-solid gl-border-b-gray-100': !sidebarCollapsed }" > <template v-if="sidebarCollapsed"> @@ -118,7 +126,7 @@ export default { class="value gl-m-0" :class="{ 'no-value': !statuses[alert.status] }" > - <span v-if="statuses[alert.status]" class="gl-text-gray-500" data-testid="status"> + <span v-if="statuses[alert.status]" :class="textClass" data-testid="status"> {{ statuses[alert.status] }} </span> <span v-else> diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb index 7af2ed3fa14..6ebf7c7c263 100644 --- a/app/workers/concerns/gitlab/github_import/object_importer.rb +++ b/app/workers/concerns/gitlab/github_import/object_importer.rb @@ -27,15 +27,19 @@ module Gitlab # client - An instance of `Gitlab::GithubImport::Client` # hash - A Hash containing the details of the object to import. def import(project, client, hash) + object = representation_class.from_json_hash(hash) + + # To better express in the logs what object is being imported. + self.github_id = object.attributes.fetch(:github_id) + info(project.id, message: 'starting importer') - object = representation_class.from_json_hash(hash) importer_class.new(object, project, client).execute counter.increment info(project.id, message: 'importer finished') rescue StandardError => e - error(project.id, e) + error(project.id, e, hash) end def counter @@ -65,16 +69,19 @@ module Gitlab private + attr_accessor :github_id + def info(project_id, extra = {}) logger.info(log_attributes(project_id, extra)) end - def error(project_id, exception) + def error(project_id, exception, data = {}) logger.error( log_attributes( project_id, message: 'importer failed', - 'error.message': exception.message + 'error.message': exception.message, + 'github.data': data ) ) @@ -88,7 +95,8 @@ module Gitlab extra.merge( import_source: :github, project_id: project_id, - importer: importer_class.name + importer: importer_class.name, + github_id: github_id ) end end diff --git a/changelogs/unreleased/331092-remove-subscribed-from-graphql-boards-list-query.yml b/changelogs/unreleased/331092-remove-subscribed-from-graphql-boards-list-query.yml new file mode 100644 index 00000000000..8050aea1928 --- /dev/null +++ b/changelogs/unreleased/331092-remove-subscribed-from-graphql-boards-list-query.yml @@ -0,0 +1,5 @@ +--- +title: Resolve Remove `subscribed` from GraphQL boards list query +merge_request: 61881 +author: +type: performance diff --git a/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml b/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml new file mode 100644 index 00000000000..a37a470cb67 --- /dev/null +++ b/changelogs/unreleased/backfill-clusters-integration-elatic-stack-enabled.yml @@ -0,0 +1,5 @@ +--- +title: Backfill clusters_integration_elastic_stack.enabled +merge_request: 61521 +author: +type: changed diff --git a/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb b/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb new file mode 100644 index 00000000000..6d21945af00 --- /dev/null +++ b/db/post_migrate/20210518001450_backfill_clusters_integration_elastic_stack_enabled.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class BackfillClustersIntegrationElasticStackEnabled < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + ApplicationRecord.connection.execute(<<~SQL.squish) + INSERT INTO clusters_integration_elasticstack( + cluster_id, + enabled, + chart_version, + created_at, + updated_at + ) + SELECT + cluster_id, + true, + version, + TIMEZONE('UTC', NOW()), + TIMEZONE('UTC', NOW()) + FROM clusters_applications_elastic_stacks + WHERE status IN (3, 11) + ON CONFLICT(cluster_id) DO UPDATE SET + enabled = true, + updated_at = TIMEZONE('UTC', NOW()) + SQL + end + + def down + # Irreversible + end +end diff --git a/db/schema_migrations/20210518001450 b/db/schema_migrations/20210518001450 new file mode 100644 index 00000000000..5f3694d8b93 --- /dev/null +++ b/db/schema_migrations/20210518001450 @@ -0,0 +1 @@ +212a2db8b1183eb4ae313eacae7d54f2bec26c5ea3f961981d34e57ca1420ad9
\ No newline at end of file diff --git a/doc/development/contributing/merge_request_workflow.md b/doc/development/contributing/merge_request_workflow.md index 771a9caafe5..922bc52773b 100644 --- a/doc/development/contributing/merge_request_workflow.md +++ b/doc/development/contributing/merge_request_workflow.md @@ -250,6 +250,8 @@ requirements. with any questions. 1. The new feature does not degrade the user experience of the product. +Contributions do not require approval from the [Product team](https://about.gitlab.com/handbook/product/product-processes/#gitlab-pms-arent-the-arbiters-of-community-contributions). + ## Dependencies If you add a dependency in GitLab (such as an operating system package) please diff --git a/doc/user/application_security/threat_monitoring/index.md b/doc/user/application_security/threat_monitoring/index.md index 8e9125669db..825bc64d52b 100644 --- a/doc/user/application_security/threat_monitoring/index.md +++ b/doc/user/application_security/threat_monitoring/index.md @@ -228,7 +228,7 @@ By default, the list doesn't display resolved or dismissed alerts. ![Policy Alert List](img/threat_monitoring_policy_alert_list_v13_12.png) Clicking an alert's row opens the alert drawer, which shows more information about the alert. A user -can also create an incident from the alert in the alert drawer. +can also create an incident from the alert and update the alert status in the alert drawer. Clicking an alert's name takes the user to the [alert details page](../../../operations/incident_management/alerts.md#alert-details-page). diff --git a/lib/gitlab/github_import/representation/issue.rb b/lib/gitlab/github_import/representation/issue.rb index f3071b3e2b3..0e04b5ad57f 100644 --- a/lib/gitlab/github_import/representation/issue.rb +++ b/lib/gitlab/github_import/representation/issue.rb @@ -25,6 +25,7 @@ module Gitlab hash = { iid: issue.number, + github_id: issue.number, title: issue.title, description: issue.body, milestone_number: issue.milestone&.number, diff --git a/lib/gitlab/github_import/representation/lfs_object.rb b/lib/gitlab/github_import/representation/lfs_object.rb index a4606173f49..41723759645 100644 --- a/lib/gitlab/github_import/representation/lfs_object.rb +++ b/lib/gitlab/github_import/representation/lfs_object.rb @@ -13,7 +13,12 @@ module Gitlab # Builds a lfs_object def self.from_api_response(lfs_object) - new({ oid: lfs_object.oid, link: lfs_object.link, size: lfs_object.size }) + new( + oid: lfs_object.oid, + link: lfs_object.link, + size: lfs_object.size, + github_id: lfs_object.oid + ) end # Builds a new lfs_object using a Hash that was built from a JSON payload. diff --git a/lib/gitlab/github_import/representation/pull_request.rb b/lib/gitlab/github_import/representation/pull_request.rb index be192762e05..e4f54fcc833 100644 --- a/lib/gitlab/github_import/representation/pull_request.rb +++ b/lib/gitlab/github_import/representation/pull_request.rb @@ -25,6 +25,7 @@ module Gitlab hash = { iid: pr.number, + github_id: pr.number, title: pr.title, description: pr.body, source_branch: pr.head.ref, diff --git a/lib/gitlab/github_import/representation/user.rb b/lib/gitlab/github_import/representation/user.rb index e00dcfca33d..d97b90b6291 100644 --- a/lib/gitlab/github_import/representation/user.rb +++ b/lib/gitlab/github_import/representation/user.rb @@ -15,7 +15,11 @@ module Gitlab # # user - An instance of `Sawyer::Resource` containing the user details. def self.from_api_response(user) - new(id: user.id, login: user.login) + new( + id: user.id, + github_id: user.id, + login: user.login + ) end # Builds a user using a Hash that was built from a JSON payload. diff --git a/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js b/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js index 80eea6c19c2..d5be5b623b8 100644 --- a/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js +++ b/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js @@ -121,6 +121,13 @@ describe('Alert Details Sidebar Status', () => { expect(findStatus().text()).toBe('Triggered'); }); + it('emits "alert-update" when the status has been updated', () => { + mountComponent({ sidebarCollapsed: false }); + expect(wrapper.emitted('alert-update')).toBeUndefined(); + findAlertStatus().vm.$emit('handle-updating'); + expect(wrapper.emitted('alert-update')).toEqual([[]]); + }); + it('renders translated statuses', () => { const status = 'TEST'; const statuses = { [status]: 'Test' }; diff --git a/spec/initializers/pages_storage_check_spec.rb b/spec/initializers/pages_storage_check_spec.rb index a76002dbdcf..e81802ae669 100644 --- a/spec/initializers/pages_storage_check_spec.rb +++ b/spec/initializers/pages_storage_check_spec.rb @@ -9,7 +9,7 @@ RSpec.describe 'pages storage check' do context 'when local store does not exist yet' do before do - Settings.pages['local_store'] = nil + stub_config(pages: { enabled: true, local_store: nil }) end it { is_expected.to be_truthy } @@ -17,78 +17,42 @@ RSpec.describe 'pages storage check' do context 'when pages is not enabled' do before do - Settings.pages['enabled'] = false + stub_config(pages: { enabled: false }) end it { is_expected.to be_truthy } end context 'when pages is enabled' do - before do - Settings.pages['enabled'] = true - Settings.pages['local_store'] = Settingslogic.new({}) + using RSpec::Parameterized::TableSyntax + + where(:local_storage_enabled, :object_storage_enabled, :raises_exception) do + false | false | true + false | true | false + true | false | false + true | true | false + 1 | 0 | false + nil | nil | true end - context 'when pages object storage is not enabled' do + with_them do before do - Settings.pages['object_store']['enabled'] = false + stub_config( + pages: { + enabled: true, + local_store: { enabled: local_storage_enabled }, + object_store: { enabled: object_storage_enabled } + } + ) end - context 'when pages local storage is not enabled' do - it 'raises an exception' do - Settings.pages['local_store']['enabled'] = false - + it 'validates pages storage configuration' do + if raises_exception expect { subject }.to raise_error(main_error_message) - end - end - - context 'when pages local storage is enabled' do - it 'is true' do - Settings.pages['local_store']['enabled'] = true - - expect(subject).to be_truthy - end - end - end - - context 'when pages object storage is enabled' do - before do - Settings.pages['object_store']['enabled'] = true - end - - context 'when pages local storage is not enabled' do - it 'is true' do - Settings.pages['local_store']['enabled'] = false - + else expect(subject).to be_truthy end end - - context 'when pages local storage is enabled' do - it 'is true' do - Settings.pages['local_store']['enabled'] = true - - expect(subject).to be_truthy - end - end - end - - context 'when using integers instead of booleans' do - it 'is true' do - Settings.pages['local_store']['enabled'] = 1 - Settings.pages['object_store']['enabled'] = 0 - - expect(subject).to be_truthy - end - end - - context 'when both enabled attributes are not set' do - it 'raises an exception' do - Settings.pages['local_store']['enabled'] = nil - Settings.pages['object_store']['enabled'] = nil - - expect { subject }.to raise_error(main_error_message) - end end end end diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb index 75f2c7922de..85e1721461f 100644 --- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb @@ -18,39 +18,49 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do def counter_description 'This is a counter' end + + def representation_class + MockRepresantation + end end.new end + before do + stub_const('MockRepresantation', Class.new do + include Gitlab::GithubImport::Representation::ToHash + include Gitlab::GithubImport::Representation::ExposeAttribute + + def self.from_json_hash(raw_hash) + new(Gitlab::GithubImport::Representation.symbolize_hash(raw_hash)) + end + + attr_reader :attributes + + def initialize(attributes) + @attributes = attributes + end + end) + end + describe '#import' do - let(:representation_class) { double(:representation_class) } let(:importer_class) { double(:importer_class, name: 'klass_name') } let(:importer_instance) { double(:importer_instance) } - let(:representation) { double(:representation) } let(:project) { double(:project, full_path: 'foo/bar', id: 1) } let(:client) { double(:client) } before do expect(worker) - .to receive(:representation_class) - .and_return(representation_class) - - expect(worker) .to receive(:importer_class) .at_least(:once) .and_return(importer_class) + end - expect(representation_class) - .to receive(:from_json_hash) - .with(an_instance_of(Hash)) - .and_return(representation) - + it 'imports the object' do expect(importer_class) .to receive(:new) - .with(representation, project, client) + .with(instance_of(MockRepresantation), project, client) .and_return(importer_instance) - end - it 'imports the object' do expect(importer_instance) .to receive(:execute) @@ -62,6 +72,7 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do expect(logger) .to receive(:info) .with( + github_id: 1, message: 'starting importer', import_source: :github, project_id: 1, @@ -70,6 +81,7 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do expect(logger) .to receive(:info) .with( + github_id: 1, message: 'importer finished', import_source: :github, project_id: 1, @@ -77,10 +89,15 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do ) end - worker.import(project, client, { 'number' => 10 }) + worker.import(project, client, { 'number' => 10, 'github_id' => 1 }) end it 'logs error when the import fails' do + expect(importer_class) + .to receive(:new) + .with(instance_of(MockRepresantation), project, client) + .and_return(importer_instance) + exception = StandardError.new('some error') expect(importer_instance) .to receive(:execute) @@ -90,6 +107,7 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do expect(logger) .to receive(:info) .with( + github_id: 1, message: 'starting importer', import_source: :github, project_id: project.id, @@ -98,20 +116,64 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter do expect(logger) .to receive(:error) .with( + github_id: 1, message: 'importer failed', import_source: :github, project_id: project.id, importer: 'klass_name', - 'error.message': 'some error' + 'error.message': 'some error', + 'github.data': { + 'github_id' => 1, + 'number' => 10 + } ) end expect(Gitlab::ErrorTracking) .to receive(:track_and_raise_exception) - .with(exception, import_source: :github, project_id: 1, importer: 'klass_name') - .and_call_original + .with( + exception, + import_source: :github, + github_id: 1, + project_id: 1, + importer: 'klass_name' + ).and_call_original + + expect { worker.import(project, client, { 'number' => 10, 'github_id' => 1 }) } + .to raise_error(exception) + end + + it 'logs error when representation does not have a github_id' do + expect(importer_class).not_to receive(:new) + + expect_next_instance_of(Gitlab::Import::Logger) do |logger| + expect(logger) + .to receive(:error) + .with( + github_id: nil, + message: 'importer failed', + import_source: :github, + project_id: project.id, + importer: 'klass_name', + 'error.message': 'key not found: :github_id', + 'github.data': { + 'number' => 10 + } + ) + end - expect { worker.import(project, client, { 'number' => 10 }) }.to raise_error(exception) + expect(Gitlab::ErrorTracking) + .to receive(:track_and_raise_exception) + .with( + an_instance_of(KeyError), + import_source: :github, + github_id: nil, + project_id: 1, + importer: 'klass_name' + ).and_call_original + + expect { worker.import(project, client, { 'number' => 10 }) } + .to raise_error(KeyError, 'key not found: :github_id') end end diff --git a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb index 4039cdac721..6476d82eb85 100644 --- a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GithubImport::ImportDiffNoteWorker do importer = double(:importer) hash = { 'noteable_id' => 42, + 'github_id' => 42, 'path' => 'README.md', 'commit_id' => '123abc', 'diff_hunk' => "@@ -1 +1 @@\n-Hello\n+Hello world", diff --git a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb index c25e89f6928..9f5bd1d9e5e 100644 --- a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GithubImport::ImportIssueWorker do importer = double(:importer) hash = { 'iid' => 42, + 'github_id' => 42, 'title' => 'My Issue', 'description' => 'This is my issue', 'milestone_number' => 4, diff --git a/spec/workers/gitlab/github_import/import_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_note_worker_spec.rb index bfb40d7c3d3..94bc8e26e4a 100644 --- a/spec/workers/gitlab/github_import/import_note_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_note_worker_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GithubImport::ImportNoteWorker do importer = double(:importer) hash = { 'noteable_id' => 42, + 'github_id' => 42, 'noteable_type' => 'issues', 'user' => { 'id' => 4, 'login' => 'alice' }, 'note' => 'Hello world', diff --git a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb index 12b21abf910..1238929fbcb 100644 --- a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb +++ b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GithubImport::ImportPullRequestWorker do importer = double(:importer) hash = { 'iid' => 42, + 'github_id' => 42, 'title' => 'My Pull Request', 'description' => 'This is my pull request', 'source_branch' => 'my-feature', |