Commit 229adda8 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fix-older-deployment-drop-service' into 'master'

Fix OlderDeploymentsDropService drops manual deployments

See merge request gitlab-org/gitlab!76632
parents 7739ba28 1c2bca94
......@@ -12,6 +12,8 @@ module Deployments
return unless @deployment&.running?
older_deployments_builds.each do |build|
next if build.manual?
Gitlab::OptimisticLocking.retry_lock(build, name: 'older_deployments_drop') do |build|
build.drop(:forward_deployment_failure)
end
......
......@@ -70,13 +70,12 @@ RSpec.describe Deployments::OlderDeploymentsDropService do
let(:older_deployment) { create(:deployment, :created, environment: environment, deployable: build) }
let(:build) { create(:ci_build, :manual) }
it 'drops the older deployment' do
deployable = older_deployment.deployable
expect(deployable.failed?).to be_falsey
# Manual jobs should not be accounted as outdated deployment jobs.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/255978 for more information.
it 'does not drop any builds nor track the exception' do
expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
subject
expect(deployable.reload.failed?).to be_truthy
expect { subject }.not_to change { Ci::Build.failed.count }
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