Commit a2d82d4c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'fix-ci-job-auto-retry' into 'master'

Prevent auto-retry AccessDenied error from stopping transition to failed

See merge request gitlab-org/gitlab-ce!17862
parents 500132e0 9c9c0484
...@@ -140,7 +140,11 @@ module Ci ...@@ -140,7 +140,11 @@ module Ci
next if build.retries_max.zero? next if build.retries_max.zero?
if build.retries_count < build.retries_max if build.retries_count < build.retries_max
begin
Ci::Build.retry(build, build.user) Ci::Build.retry(build, build.user)
rescue Gitlab::Access::AccessDeniedError => ex
Rails.logger.error "Unable to auto-retry job #{build.id}: #{ex}"
end
end end
end end
......
---
title: Prevent auto-retry AccessDenied error from stopping transition to failed
merge_request: 17862
author:
type: fixed
...@@ -2101,6 +2101,35 @@ describe Ci::Build do ...@@ -2101,6 +2101,35 @@ describe Ci::Build do
subject.drop! subject.drop!
end end
context 'when retry service raises Gitlab::Access::AccessDeniedError exception' do
let(:retry_service) { Ci::RetryBuildService.new(subject.project, subject.user) }
before do
allow_any_instance_of(Ci::RetryBuildService)
.to receive(:execute)
.with(subject)
.and_raise(Gitlab::Access::AccessDeniedError)
allow(Rails.logger).to receive(:error)
end
it 'handles raised exception' do
expect { subject.drop! }.not_to raise_exception(Gitlab::Access::AccessDeniedError)
end
it 'logs the error' do
subject.drop!
expect(Rails.logger)
.to have_received(:error)
.with(a_string_matching("Unable to auto-retry job #{subject.id}"))
end
it 'fails the job' do
subject.drop!
expect(subject.failed?).to be_truthy
end
end
end end
context 'when build is not configured to be retried' do context 'when build is not configured to be retried' do
......
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