Commit cd2f34b7 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'remove-transactionless-destroy-feature-flag' into 'master'

Remove project_transactionless_destroy flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!55795
parents 77fb4ebc fc194ab2
...@@ -107,12 +107,7 @@ module Projects ...@@ -107,12 +107,7 @@ module Projects
end end
project.leave_pool_repository project.leave_pool_repository
destroy_project_related_records(project)
if Gitlab::Ci::Features.project_transactionless_destroy?(project)
destroy_project_related_records(project)
else
Project.transaction { destroy_project_related_records(project) }
end
end end
def destroy_project_related_records(project) def destroy_project_related_records(project)
......
---
title: Remove project_transactionless_destroy feature flag
merge_request: 55795
author:
type: changed
---
name: project_transactionless_destroy
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39367
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/255972
milestone: '13.4'
type: development
group: group::continuous integration
default_enabled: false
...@@ -20,93 +20,79 @@ RSpec.describe Projects::DestroyService do ...@@ -20,93 +20,79 @@ RSpec.describe Projects::DestroyService do
stub_container_registry_tags(repository: :any, tags: []) stub_container_registry_tags(repository: :any, tags: [])
end end
shared_examples 'project destroy ee' do context 'when project is a mirror' do
context 'when project is a mirror' do let(:max_capacity) { Gitlab::CurrentSettings.mirror_max_capacity }
let(:max_capacity) { Gitlab::CurrentSettings.mirror_max_capacity } let_it_be(:project_mirror) { create(:project, :mirror, :repository, :import_scheduled) }
let_it_be(:project_mirror) { create(:project, :mirror, :repository, :import_scheduled) } let(:result) { described_class.new(project_mirror, project_mirror.owner, {}).execute }
let(:result) { described_class.new(project_mirror, project_mirror.owner, {}).execute }
before do
Gitlab::Mirror.increment_capacity(project_mirror.id)
end
it 'decrements capacity if mirror was scheduled' do before do
expect {result}.to change { Gitlab::Mirror.available_capacity }.from(max_capacity - 1).to(max_capacity) Gitlab::Mirror.increment_capacity(project_mirror.id)
end
end end
context 'when running on a primary node' do it 'decrements capacity if mirror was scheduled' do
let_it_be(:primary) { create(:geo_node, :primary) } expect {result}.to change { Gitlab::Mirror.available_capacity }.from(max_capacity - 1).to(max_capacity)
let_it_be(:secondary) { create(:geo_node) } end
end
before do
stub_current_geo_node(primary)
end
it 'logs an event to the Geo event log' do context 'when running on a primary node' do
# Run Sidekiq immediately to check that renamed repository will be removed let_it_be(:primary) { create(:geo_node, :primary) }
Sidekiq::Testing.inline! do let_it_be(:secondary) { create(:geo_node) }
expect(subject).to receive(:log_destroy_events).and_call_original
expect { subject.execute }.to change(Geo::RepositoryDeletedEvent, :count).by(1)
end
end
it 'does not log event to the Geo log if project deletion fails' do before do
expect(subject).to receive(:log_destroy_event).and_call_original stub_current_geo_node(primary)
expect(project).to receive(:destroy!).and_raise(StandardError.new('Other error message')) end
Sidekiq::Testing.inline! do it 'logs an event to the Geo event log' do
expect { subject.execute }.not_to change(Geo::RepositoryDeletedEvent, :count) # Run Sidekiq immediately to check that renamed repository will be removed
end Sidekiq::Testing.inline! do
expect(subject).to receive(:log_destroy_events).and_call_original
expect { subject.execute }.to change(Geo::RepositoryDeletedEvent, :count).by(1)
end end
end end
context 'audit events' do it 'does not log event to the Geo log if project deletion fails' do
include_examples 'audit event logging' do expect(subject).to receive(:log_destroy_event).and_call_original
let(:operation) { subject.execute } expect(project).to receive(:destroy!).and_raise(StandardError.new('Other error message'))
let(:fail_condition!) do Sidekiq::Testing.inline! do
expect(project).to receive(:destroy!).and_raise(StandardError.new('Other error message')) expect { subject.execute }.not_to change(Geo::RepositoryDeletedEvent, :count)
end
let(:attributes) do
{
author_id: user.id,
entity_id: project.id,
entity_type: 'Project',
details: {
remove: 'project',
author_name: user.name,
target_id: project.id,
target_type: 'Project',
target_details: project.full_path
}
}
end
end end
end end
end
context 'audit events' do
include_examples 'audit event logging' do
let(:operation) { subject.execute }
context 'system hooks exception' do let(:fail_condition!) do
before do expect(project).to receive(:destroy!).and_raise(StandardError.new('Other error message'))
allow_any_instance_of(SystemHooksService).to receive(:execute_hooks_for).and_raise('something went wrong')
end end
it 'logs an audit event' do let(:attributes) do
expect(subject).to receive(:log_destroy_event).and_call_original {
expect { subject.execute }.to change(AuditEvent, :count) author_id: user.id,
entity_id: project.id,
entity_type: 'Project',
details: {
remove: 'project',
author_name: user.name,
target_id: project.id,
target_type: 'Project',
target_details: project.full_path
}
}
end end
end end
end end
context 'when project_transactionless_destroy enabled' do context 'system hooks exception' do
it_behaves_like 'project destroy ee'
end
context 'when project_transactionless_destroy disabled', :sidekiq_inline do
before do before do
stub_feature_flags(project_transactionless_destroy: false) allow_any_instance_of(SystemHooksService).to receive(:execute_hooks_for).and_raise('something went wrong')
end end
it_behaves_like 'project destroy ee' it 'logs an audit event' do
expect(subject).to receive(:log_destroy_event).and_call_original
expect { subject.execute }.to change(AuditEvent, :count)
end
end end
end end
...@@ -38,10 +38,6 @@ module Gitlab ...@@ -38,10 +38,6 @@ module Gitlab
::Feature.enabled?(:ci_disallow_to_create_merge_request_pipelines_in_target_project, target_project) ::Feature.enabled?(:ci_disallow_to_create_merge_request_pipelines_in_target_project, target_project)
end end
def self.project_transactionless_destroy?(project)
Feature.enabled?(:project_transactionless_destroy, project, default_enabled: false)
end
def self.trace_overwrite? def self.trace_overwrite?
::Feature.enabled?(:ci_trace_overwrite, type: :ops, default_enabled: false) ::Feature.enabled?(:ci_trace_overwrite, type: :ops, default_enabled: false)
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