Commit 4c9d2e3a authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'atomic-pages-deploy-stuck' into 'master'

Fix pages build locking problem

See merge request gitlab-org/gitlab!32554
parents b7524f8f 8d228998
......@@ -2,6 +2,8 @@
module Projects
class UpdatePagesService < BaseService
include Gitlab::OptimisticLocking
InvalidStateError = Class.new(StandardError)
FailedToExtractError = Class.new(StandardError)
......@@ -23,8 +25,8 @@ module Projects
# Create status notifying the deployment of pages
@status = create_status
@status.enqueue!
@status.run!
retry_optimistic_lock(@status, &:enqueue!)
retry_optimistic_lock(@status, &:run!)
raise InvalidStateError, 'missing pages artifacts' unless build.artifacts?
raise InvalidStateError, 'build SHA is outdated for this ref' unless latest?
......@@ -51,7 +53,7 @@ module Projects
private
def success
@status.success
retry_optimistic_lock(@status, &:success)
@project.mark_pages_as_deployed
super
end
......@@ -61,7 +63,7 @@ module Projects
log_error("Projects::UpdatePagesService: #{message}")
@status.allow_failure = !latest?
@status.description = message
@status.drop(:script_failure)
retry_optimistic_lock(@status) { |status| status.drop(:script_failure) }
super
end
......
......@@ -106,7 +106,7 @@ module API
status.enqueue!
when 'running'
status.enqueue
status.run!
Gitlab::OptimisticLocking.retry_lock(status, &:run!)
when 'success'
status.success!
when 'failed'
......
......@@ -158,6 +158,23 @@ describe Projects::UpdatePagesService do
expect(project.pages_metadatum).not_to be_deployed
end
end
context 'with background jobs running', :sidekiq_inline do
where(:ci_atomic_processing) do
[true, false]
end
with_them do
before do
stub_feature_flags(ci_atomic_processing: ci_atomic_processing)
end
it 'succeeds' do
expect(project.pages_deployed?).to be_falsey
expect(execute).to eq(:success)
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