Commit 9adb247e authored by Toon Claes's avatar Toon Claes

Merge branch '277327-fix-background-migration-argument-type' into 'master'

Fix argument type for PopulateUuidsForSecurityFindings and reschedule

See merge request gitlab-org/gitlab!55097
parents e864e807 74bbd963
---
title: Fix argument type for background migration
merge_request: 55097
author:
type: fixed
......@@ -11,13 +11,7 @@ class ScheduleUuidPopulationForSecurityFindings < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
Gitlab::BackgroundMigration::PopulateUuidsForSecurityFindings.security_findings.each_batch(column: :scan_id, of: BATCH_SIZE) do |batch, index|
migrate_in(
DELAY_INTERVAL * index,
MIGRATION_CLASS,
batch.pluck(:scan_id)
)
end
# no-op, replaced by 20210111075206_schedule_uuid_population_for_security_findings2.rb
end
def down
......
# frozen_string_literal: true
# This replaces the previous post-deployment migration 20210111075105_schedule_uuid_population_for_security_findings.rb,
# we have to run this again due to a bug in how we were receiving the arguments in the background migration.
class ScheduleUuidPopulationForSecurityFindings2 < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
MIGRATION_CLASS = 'PopulateUuidsForSecurityFindings'
DELAY_INTERVAL = 2.minutes
BATCH_SIZE = 25
disable_ddl_transaction!
def up
::Gitlab::BackgroundMigration.steal(MIGRATION_CLASS) do |job|
job.delete
false
end
Gitlab::BackgroundMigration::PopulateUuidsForSecurityFindings.security_findings.each_batch(column: :scan_id, of: BATCH_SIZE) do |batch, index|
migrate_in(
DELAY_INTERVAL * index,
MIGRATION_CLASS,
batch.pluck(:scan_id)
)
end
end
def down
# no-op
end
end
9da5955d9f71d671a41e6d03f76f87370d6e67b6853707adb164f7ffa8c75082
\ No newline at end of file
......@@ -228,7 +228,7 @@ module EE
end
override :perform
def perform(scan_ids)
def perform(*scan_ids)
SecurityScan.where(id: scan_ids).includes(:pipeline, :artifacts).each(&:recover_findings)
log_info(scan_ids.count)
......
......@@ -54,7 +54,7 @@ RSpec.describe ::Gitlab::BackgroundMigration::PopulateUuidsForSecurityFindings d
end
describe '#perform' do
subject(:populate_uuids) { described_class.new.perform([security_scan_1.id, security_scan_2.id, security_scan_3.id]) }
subject(:populate_uuids) { described_class.new.perform(security_scan_1.id, security_scan_2.id, security_scan_3.id) }
it 'sets the `uuid` of findings' do
expect { populate_uuids }.to change { finding_1.reload.uuid }.from(nil)
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
require_migration!
RSpec.describe ScheduleUuidPopulationForSecurityFindings do
RSpec.describe ScheduleUuidPopulationForSecurityFindings2 do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:ci_pipelines) { table(:ci_pipelines) }
......
......@@ -10,7 +10,7 @@ module Gitlab
NOP_RELATION.new
end
def perform(_scan_ids); end
def perform(*_scan_ids); end
end
end
end
......
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