Commit bd5d3729 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'ab-cancel-pipelines-prior-to-destroy-ff-removal' into 'master'

Remove flag cancel_pipelines_prior_to_destroy

See merge request gitlab-org/gitlab!67063
parents e24b98a9 d738b594
...@@ -7,7 +7,7 @@ module Ci ...@@ -7,7 +7,7 @@ module Ci
Ci::ExpirePipelineCacheService.new.execute(pipeline, delete: true) Ci::ExpirePipelineCacheService.new.execute(pipeline, delete: true)
pipeline.cancel_running if pipeline.cancelable? && ::Feature.enabled?(:cancel_pipelines_prior_to_destroy, pipeline.project, default_enabled: :yaml) pipeline.cancel_running if pipeline.cancelable?
pipeline.reset.destroy! pipeline.reset.destroy!
......
---
name: cancel_pipelines_prior_to_destroy
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65586
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/335338
milestone: '14.1'
type: development
group: group::continuous integration
default_enabled: false
...@@ -52,9 +52,7 @@ module EE ...@@ -52,9 +52,7 @@ module EE
state_machine :status do state_machine :status do
after_transition any => [:success, :failed, :canceled] do |build| after_transition any => [:success, :failed, :canceled] do |build|
build.run_after_commit do build.run_after_commit do
if ::Feature.enabled?(:cancel_pipelines_prior_to_destroy, build.project, default_enabled: :yaml) ::Ci::Minutes::UpdateBuildMinutesService.new(build.project, nil).execute(build)
::Ci::Minutes::UpdateBuildMinutesService.new(build.project, nil).execute(build)
end
end end
end end
end end
......
...@@ -21,11 +21,7 @@ module Ci ...@@ -21,11 +21,7 @@ module Ci
private private
def update_minutes(consumption) def update_minutes(consumption)
if ::Feature.enabled?(:cancel_pipelines_prior_to_destroy, project, default_enabled: :yaml) ::Ci::Minutes::UpdateProjectAndNamespaceUsageWorker.perform_async(consumption, project.id, namespace.id)
::Ci::Minutes::UpdateProjectAndNamespaceUsageWorker.perform_async(consumption, project.id, namespace.id)
else
::Ci::Minutes::UpdateProjectAndNamespaceUsageService.new(project.id, namespace.id).execute(consumption)
end
end end
def compare_with_live_consumption(build, consumption) def compare_with_live_consumption(build, consumption)
......
...@@ -9,10 +9,6 @@ module EE ...@@ -9,10 +9,6 @@ module EE
# and enqueueing duplicate jobs. # and enqueueing duplicate jobs.
super super
unless ::Feature.enabled?(:cancel_pipelines_prior_to_destroy, build.project, default_enabled: :yaml)
::Ci::Minutes::UpdateBuildMinutesService.new(build.project, nil).execute(build)
end
unless build.project.requirements.empty? unless build.project.requirements.empty?
RequirementsManagement::ProcessRequirementsReportsWorker.perform_async(build.id) RequirementsManagement::ProcessRequirementsReportsWorker.perform_async(build.id)
end end
......
...@@ -92,33 +92,19 @@ RSpec.describe Ci::Build do ...@@ -92,33 +92,19 @@ RSpec.describe Ci::Build do
it_behaves_like 'depends on runner presence and type' it_behaves_like 'depends on runner presence and type'
end end
shared_context 'updates minutes' do context 'updates pipeline minutes' do
context 'updates pipeline minutes' do let(:job) { create(:ci_build, :running, pipeline: pipeline) }
let(:job) { create(:ci_build, :running, pipeline: pipeline) }
%w(success drop cancel).each do |event| %w(success drop cancel).each do |event|
it "for event #{event}" do it "for event #{event}" do
expect(Ci::Minutes::UpdateBuildMinutesService) expect(Ci::Minutes::UpdateBuildMinutesService)
.to receive(:new).and_call_original .to receive(:new).and_call_original
job.public_send(event) job.public_send(event)
end
end end
end end
end end
context 'when cancel_pipelines_prior_to_destroy is enabled' do
include_context 'updates minutes'
end
context 'when cancel_pipelines_prior_to_destroy is disabled', :sidekiq_inline do
before do
stub_feature_flags(cancel_pipelines_prior_to_destroy: false)
end
include_context 'updates minutes'
end
describe '#variables' do describe '#variables' do
subject { job.variables } subject { job.variables }
......
...@@ -18,7 +18,7 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do ...@@ -18,7 +18,7 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do
subject { described_class.new(project, nil).execute(build) } subject { described_class.new(project, nil).execute(build) }
shared_examples 'executes service' do describe '#execute', :sidekiq_inline do
shared_examples 'new tracking matches legacy tracking' do shared_examples 'new tracking matches legacy tracking' do
it 'stores the same information in both legacy and new tracking' do it 'stores the same information in both legacy and new tracking' do
subject subject
...@@ -253,18 +253,4 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do ...@@ -253,18 +253,4 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do
it_behaves_like 'does nothing' it_behaves_like 'does nothing'
end end
end end
describe '#execute' do
context 'when cancel_pipelines_prior_to_destroy enabled', :sidekiq_inline do
include_examples 'executes service'
end
context 'when cancel_pipelines_prior_to_destroy disabled' do
before do
stub_feature_flags(cancel_pipelines_prior_to_destroy: false)
end
include_examples 'executes service'
end
end
end end
...@@ -27,29 +27,6 @@ RSpec.describe Ci::BuildFinishedWorker do ...@@ -27,29 +27,6 @@ RSpec.describe Ci::BuildFinishedWorker do
allow_any_instance_of(EE::Project).to receive(:shared_runners_minutes_limit_enabled?).and_return(true) # rubocop:disable RSpec/AnyInstanceOf allow_any_instance_of(EE::Project).to receive(:shared_runners_minutes_limit_enabled?).and_return(true) # rubocop:disable RSpec/AnyInstanceOf
end end
context 'when cancel_pipelines_prior_to_destroy is disabled' do
before do
stub_feature_flags(cancel_pipelines_prior_to_destroy: false)
end
it 'updates the project stats' do
expect { subject }.to change { project_stats.reload.shared_runners_seconds }
end
it 'updates the namespace stats' do
expect { subject }.to change { namespace_stats.reload.shared_runners_seconds }
end
it 'notifies the owners of Groups' do
namespace.update_attribute(:shared_runners_minutes_limit, 2000)
namespace_stats.update_attribute(:shared_runners_seconds, 2100 * 60)
expect(CiMinutesUsageMailer).to receive(:notify).once.with(namespace, [namespace.owner.email]).and_return(spy)
subject
end
end
it 'tracks secure scans' do it 'tracks secure scans' do
expect(::Security::TrackSecureScansWorker).to receive(:perform_async) expect(::Security::TrackSecureScansWorker).to receive(:perform_async)
......
...@@ -437,44 +437,28 @@ RSpec.describe 'Pipeline', :js do ...@@ -437,44 +437,28 @@ RSpec.describe 'Pipeline', :js do
end end
end end
shared_context 'delete pipeline' do context 'when user can not delete' do
context 'deleting pipeline' do before do
context 'when user can not delete' do visit_pipeline
before do
visit_pipeline
end
it { expect(page).not_to have_button('Delete') }
end
context 'when deleting' do
before do
group.add_owner(user)
visit_pipeline
click_button 'Delete'
click_button 'Delete pipeline'
end
it 'redirects to pipeline overview page', :sidekiq_inline do
expect(page).to have_content('The pipeline has been deleted')
expect(current_path).to eq(project_pipelines_path(project))
end
end
end end
end
context 'when cancel_pipelines_prior_to_destroy is enabled' do it { expect(page).not_to have_button('Delete') }
include_context 'delete pipeline'
end end
context 'when cancel_pipelines_prior_to_destroy is disabled' do context 'when deleting' do
before do before do
stub_feature_flags(cancel_pipelines_prior_to_destroy: false) group.add_owner(user)
visit_pipeline
click_button 'Delete'
click_button 'Delete pipeline'
end end
include_context 'delete pipeline' it 'redirects to pipeline overview page', :sidekiq_inline do
expect(page).to have_content('The pipeline has been deleted')
expect(current_path).to eq(project_pipelines_path(project))
end
end end
context 'when pipeline ref does not exist in repository anymore' do context 'when pipeline ref does not exist in repository anymore' do
......
...@@ -78,18 +78,6 @@ RSpec.describe ::Ci::DestroyPipelineService do ...@@ -78,18 +78,6 @@ RSpec.describe ::Ci::DestroyPipelineService do
subject subject
end end
context 'when cancel_pipelines_prior_to_destroy is disabled' do
before do
stub_feature_flags(cancel_pipelines_prior_to_destroy: false)
end
it "doesn't cancel the pipeline" do
expect(pipeline).not_to receive(:cancel_running)
subject
end
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