diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/services/projects/update_pages_service.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/services/projects/update_pages_service.rb')
-rw-r--r-- | app/services/projects/update_pages_service.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb index b9c579a130f..53872c67f49 100644 --- a/app/services/projects/update_pages_service.rb +++ b/app/services/projects/update_pages_service.rb @@ -4,6 +4,9 @@ module Projects class UpdatePagesService < BaseService InvalidStateError = Class.new(StandardError) FailedToExtractError = Class.new(StandardError) + ExclusiveLeaseTaken = Class.new(StandardError) + + include ::Pages::LegacyStorageLease BLOCK_SIZE = 32.kilobytes PUBLIC_DIR = 'public' @@ -109,6 +112,17 @@ module Projects end def deploy_page!(archive_public_path) + deployed = try_obtain_lease do + deploy_page_unsafe!(archive_public_path) + true + end + + unless deployed + raise ExclusiveLeaseTaken, "Failed to deploy pages - other deployment is in progress" + end + end + + def deploy_page_unsafe!(archive_public_path) # Do atomic move of pages # Move and removal may not be atomic, but they are significantly faster then extracting and removal # 1. We move deployed public to previous public path (file removal is slow) @@ -125,8 +139,6 @@ module Projects end def create_pages_deployment(artifacts_path, build) - return unless Feature.enabled?(:zip_pages_deployments, project, default_enabled: true) - # we're using the full archive and pages daemon needs to read it # so we want the total count from entries, not only "public/" directory # because it better approximates work we need to do before we can serve the site |