Commit 1c2bca94 authored by Shinya Maeda's avatar Shinya Maeda

Fix OlderDeploymentsDropService drops manual deployments

Currently, older manual jobs are dropped in the feature,
however, this is not an ideal from users.

This commit fixes the behavior by ignoring manual jobs.

Changelog: fixed
parent 65b17a26
......@@ -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
subject
# 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)
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