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 ...@@ -12,6 +12,8 @@ module Deployments
return unless @deployment&.running? return unless @deployment&.running?
older_deployments_builds.each do |build| older_deployments_builds.each do |build|
next if build.manual?
Gitlab::OptimisticLocking.retry_lock(build, name: 'older_deployments_drop') do |build| Gitlab::OptimisticLocking.retry_lock(build, name: 'older_deployments_drop') do |build|
build.drop(:forward_deployment_failure) build.drop(:forward_deployment_failure)
end end
......
...@@ -70,13 +70,12 @@ RSpec.describe Deployments::OlderDeploymentsDropService do ...@@ -70,13 +70,12 @@ RSpec.describe Deployments::OlderDeploymentsDropService do
let(:older_deployment) { create(:deployment, :created, environment: environment, deployable: build) } let(:older_deployment) { create(:deployment, :created, environment: environment, deployable: build) }
let(:build) { create(:ci_build, :manual) } let(:build) { create(:ci_build, :manual) }
it 'drops the older deployment' do # Manual jobs should not be accounted as outdated deployment jobs.
deployable = older_deployment.deployable # See https://gitlab.com/gitlab-org/gitlab/-/issues/255978 for more information.
expect(deployable.failed?).to be_falsey 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
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