Commit 606366f1 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 7763cef1 eb93b02a
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
%li= token %li= token
%p %p
- pat_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: @target_url } - pat_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: @target_url }
= html_escape(_('You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings')) % { pat_link_start: pat_link_start, pat_link_end: '</a>'.html_safe } = html_escape(_('You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings.')) % { pat_link_start: pat_link_start, pat_link_end: '</a>'.html_safe }
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
- <%= token %> - <%= token %>
<% end %> <% end %>
<%= _('You can create a new one or check them in your personal access tokens settings %{pat_link}') % { pat_link: @target_url } %> <%= _('You can create a new one or check them in your personal access tokens settings %{pat_link}.') % { pat_link: @target_url } %>
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
= _('One or more of your personal access tokens has expired.') = _('One or more of your personal access tokens has expired.')
%p %p
- pat_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: @target_url } - pat_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: @target_url }
= html_escape(_('You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings')) % { pat_link_start: pat_link_start, pat_link_end: '</a>'.html_safe } = html_escape(_('You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings.')) % { pat_link_start: pat_link_start, pat_link_end: '</a>'.html_safe }
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
<%= _('One or more of your personal access tokens has expired.') %> <%= _('One or more of your personal access tokens has expired.') %>
<%= _('You can create a new one or check them in your personal access tokens settings %{pat_link}') % { pat_link: @target_url } %> <%= _('You can create a new one or check them in your personal access tokens settings %{pat_link}.') % { pat_link: @target_url } %>
# frozen_string_literal: true # frozen_string_literal: true
class ScheduleLatestPipelineIdPopulation < ActiveRecord::Migration[6.1] class ScheduleLatestPipelineIdPopulation < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
DELAY_INTERVAL = 2.minutes.to_i
BATCH_SIZE = 100
MIGRATION = 'PopulateLatestPipelineIds'
disable_ddl_transaction!
def up def up
return unless Gitlab.ee? # no-op: This migration has been marked as no-op and replaced by
# `ReScheduleLatestPipelineIdPopulation` as we've found some problems.
queue_background_migration_jobs_by_range_at_intervals( # For more information: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65280
Gitlab::BackgroundMigration::PopulateLatestPipelineIds::ProjectSetting.has_vulnerabilities_without_latest_pipeline_set,
MIGRATION,
DELAY_INTERVAL,
batch_size: BATCH_SIZE,
primary_column_name: 'project_id'
)
end end
def down def down
......
# frozen_string_literal: true
class ReScheduleLatestPipelineIdPopulation < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
DELAY_INTERVAL = 2.minutes.to_i
BATCH_SIZE = 100
MIGRATION = 'PopulateLatestPipelineIds'
disable_ddl_transaction!
def up
return unless Gitlab.ee?
queue_background_migration_jobs_by_range_at_intervals(
Gitlab::BackgroundMigration::PopulateLatestPipelineIds::ProjectSetting.has_vulnerabilities_without_latest_pipeline_set,
MIGRATION,
DELAY_INTERVAL,
batch_size: BATCH_SIZE,
primary_column_name: 'project_id'
)
end
def down
# no-op
end
end
ed0daff7120cbdba2f0e9ca1f2e40c11114bb2c7db4543903d16891ffbbba3f8
\ No newline at end of file
...@@ -135,6 +135,10 @@ module EE ...@@ -135,6 +135,10 @@ module EE
return unless latest_pipeline_id return unless latest_pipeline_id
[id, DEFAULT_LETTER_GRADE, latest_pipeline_id, quoted_time, quoted_time].join(', ').then { |s| "(#{s})" } [id, DEFAULT_LETTER_GRADE, latest_pipeline_id, quoted_time, quoted_time].join(', ').then { |s| "(#{s})" }
rescue StandardError => e
::Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
nil
end end
private private
...@@ -199,7 +203,7 @@ module EE ...@@ -199,7 +203,7 @@ module EE
def root_ref def root_ref
raw_repository&.root_ref raw_repository&.root_ref
rescue Gitlab::Git::Repository::NoRepository rescue ::Gitlab::Git::Repository::NoRepository
end end
def empty? def empty?
......
...@@ -31,6 +31,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do ...@@ -31,6 +31,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do
let!(:project_2) { projects.create!(namespace_id: namespace.id, name: 'Foo 2') } let!(:project_2) { projects.create!(namespace_id: namespace.id, name: 'Foo 2') }
let!(:project_3) { projects.create!(namespace_id: namespace.id, name: 'Foo 3') } let!(:project_3) { projects.create!(namespace_id: namespace.id, name: 'Foo 3') }
let!(:project_4) { projects.create!(namespace_id: namespace.id, name: 'Foo 4') } let!(:project_4) { projects.create!(namespace_id: namespace.id, name: 'Foo 4') }
let!(:project_5) { projects.create!(namespace_id: namespace.id, name: 'Foo 5', path: 'unknown-path-to-repository') }
let!(:project_6) { projects.create!(namespace_id: namespace.id, name: 'Foo 6') }
let!(:project_1_pipeline) { pipelines.create!(project_id: project_1.id, ref: 'master', sha: 'adf43c3a', status: 'success') } let!(:project_1_pipeline) { pipelines.create!(project_id: project_1.id, ref: 'master', sha: 'adf43c3a', status: 'success') }
let!(:project_1_latest_pipeline) { pipelines.create!(project_id: project_1.id, ref: 'master', sha: 'adf43c3a', status: 'failed') } let!(:project_1_latest_pipeline) { pipelines.create!(project_id: project_1.id, ref: 'master', sha: 'adf43c3a', status: 'failed') }
...@@ -51,6 +53,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do ...@@ -51,6 +53,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do
project_settings.create!(project_id: project_2.id, has_vulnerabilities: true) project_settings.create!(project_id: project_2.id, has_vulnerabilities: true)
project_settings.create!(project_id: project_3.id) project_settings.create!(project_id: project_3.id)
project_settings.create!(project_id: project_4.id, has_vulnerabilities: true) project_settings.create!(project_id: project_4.id, has_vulnerabilities: true)
project_settings.create!(project_id: project_5.id, has_vulnerabilities: true)
project_settings.create!(project_id: project_6.id, has_vulnerabilities: true)
# Create security builds # Create security builds
create_security_build_for(project_1_pipeline, file_type: file_types[:sast]) create_security_build_for(project_1_pipeline, file_type: file_types[:sast])
...@@ -63,7 +67,20 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do ...@@ -63,7 +67,20 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do
end end
describe '#perform' do describe '#perform' do
subject(:populate_latest_pipeline_ids) { migrator.perform(project_1.id, project_4.id) } subject(:populate_latest_pipeline_ids) { migrator.perform(project_1.id, project_6.id) }
before do
allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
# Raise a RuntimeError while retreiving the `pipeline_with_reports` for the `project_6`
allow_next_found_instance_of(described_class::Project) do |project_instance|
original_pipeline_with_reports = project_instance.method(:pipeline_with_reports)
allow(project_instance).to receive(:pipeline_with_reports) do
project_instance.id == project_6.id ? raise("Foo") : original_pipeline_with_reports.call
end
end
end
it 'sets the latest_pipeline_id' do it 'sets the latest_pipeline_id' do
expect { populate_latest_pipeline_ids }.to change { project_4_stats.reload.latest_pipeline_id }.from(nil).to(project_4_pipeline.id) expect { populate_latest_pipeline_ids }.to change { project_4_stats.reload.latest_pipeline_id }.from(nil).to(project_4_pipeline.id)
...@@ -71,6 +88,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do ...@@ -71,6 +88,8 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateLatestPipelineIds do
.and change { vulnerability_statistics.find_by(project_id: project_1.id) }.from(nil) .and change { vulnerability_statistics.find_by(project_id: project_1.id) }.from(nil)
.and change { vulnerability_statistics.find_by(project_id: project_1.id)&.latest_pipeline_id }.from(nil).to(project_1_latest_pipeline.id) .and change { vulnerability_statistics.find_by(project_id: project_1.id)&.latest_pipeline_id }.from(nil).to(project_1_latest_pipeline.id)
.and not_change { project_2_stats.reload.latest_pipeline_id }.from(project_2_pipeline.id) .and not_change { project_2_stats.reload.latest_pipeline_id }.from(project_2_pipeline.id)
expect(Gitlab::ErrorTracking).to have_received(:track_and_raise_for_dev_exception).once
end end
end end
......
...@@ -37280,7 +37280,7 @@ msgstr "" ...@@ -37280,7 +37280,7 @@ msgstr ""
msgid "You can create a new SSH key by visiting %{link}" msgid "You can create a new SSH key by visiting %{link}"
msgstr "" msgstr ""
msgid "You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings" msgid "You can create a new one or check them in your %{pat_link_start}personal access tokens%{pat_link_end} settings."
msgstr "" msgstr ""
msgid "You can create a new one or check them in your %{ssh_key_link_start}SSH keys%{ssh_key_link_end} settings." msgid "You can create a new one or check them in your %{ssh_key_link_start}SSH keys%{ssh_key_link_end} settings."
...@@ -37289,7 +37289,7 @@ msgstr "" ...@@ -37289,7 +37289,7 @@ msgstr ""
msgid "You can create a new one or check them in your SSH keys settings %{ssh_key_link}." msgid "You can create a new one or check them in your SSH keys settings %{ssh_key_link}."
msgstr "" msgstr ""
msgid "You can create a new one or check them in your personal access tokens settings %{pat_link}" msgid "You can create a new one or check them in your personal access tokens settings %{pat_link}."
msgstr "" msgstr ""
msgid "You can create new ones at your %{pat_link_start}Personal Access Tokens%{pat_link_end} settings" msgid "You can create new ones at your %{pat_link_start}Personal Access Tokens%{pat_link_end} settings"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require_migration! require_migration!
RSpec.describe ScheduleLatestPipelineIdPopulation do RSpec.describe ReScheduleLatestPipelineIdPopulation do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
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