Commit 77c12001 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch...

Merge branch '345883-destroying-a-ci-jobartifact-causes-a-cross-database-modification-across-unsupported-tables-error' into 'master'

Fixes cross-db modification when destroying a Ci::JobArtifact

See merge request gitlab-org/gitlab!74737
parents 52a6c526 1517b07e
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
# After destroy callbacks are often skipped because of FastDestroyAll. # After destroy callbacks are often skipped because of FastDestroyAll.
# All destroy callbacks should be implemented in `Ci::JobArtifacts::DestroyBatchService` # All destroy callbacks should be implemented in `Ci::JobArtifacts::DestroyBatchService`
# See https://gitlab.com/gitlab-org/gitlab/-/issues/297472 # See https://gitlab.com/gitlab-org/gitlab/-/issues/297472
after_destroy :log_geo_deleted_event after_commit :log_geo_deleted_event, on: :destroy
LICENSE_SCANNING_REPORT_FILE_TYPES = %w[license_scanning].freeze LICENSE_SCANNING_REPORT_FILE_TYPES = %w[license_scanning].freeze
DEPENDENCY_LIST_REPORT_FILE_TYPES = %w[dependency_scanning].freeze DEPENDENCY_LIST_REPORT_FILE_TYPES = %w[dependency_scanning].freeze
......
...@@ -12,14 +12,27 @@ RSpec.describe Ci::JobArtifact do ...@@ -12,14 +12,27 @@ RSpec.describe Ci::JobArtifact do
let_it_be(:primary) { create(:geo_node, :primary) } let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
it 'creates a JobArtifactDeletedEvent' do before do
stub_current_geo_node(primary) stub_current_geo_node(primary)
end
it 'creates a JobArtifactDeletedEvent' do
job_artifact = create(:ee_ci_job_artifact, :archive)
expect { job_artifact.destroy! }.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
end
context 'JobArtifact destroy fails' do
it 'does not create a JobArtifactDeletedEvent' do
job_artifact = create(:ee_ci_job_artifact, :archive) job_artifact = create(:ee_ci_job_artifact, :archive)
expect do allow(job_artifact).to receive(:destroy!)
job_artifact.destroy! .and_raise(ActiveRecord::RecordNotDestroyed)
end.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
expect { job_artifact.destroy! }.to raise_error(ActiveRecord::RecordNotDestroyed)
.and not_change { Ci::JobArtifact.count }
.and not_change { Geo::JobArtifactDeletedEvent.count }
end
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