diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-11-22 16:29:03 +0100 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-11-23 14:19:36 +0100 |
commit | 05876a49c67fd94777801c09129e7dd77873e668 (patch) | |
tree | 221b53fe3da9d8e6f469a7af347d8d3e098c3f4e /app/workers | |
parent | 10c2ba7dbbae15cde019135fe89b20dbd793dadf (diff) | |
download | gitlab-ce-05876a49c67fd94777801c09129e7dd77873e668.tar.gz |
fix exclusive lease specs fro hashed storage migration
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/project_migrate_hashed_storage_worker.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/workers/project_migrate_hashed_storage_worker.rb b/app/workers/project_migrate_hashed_storage_worker.rb index e3ecd6bc950..127aa6b9d7d 100644 --- a/app/workers/project_migrate_hashed_storage_worker.rb +++ b/app/workers/project_migrate_hashed_storage_worker.rb @@ -8,23 +8,23 @@ class ProjectMigrateHashedStorageWorker project = Project.find_by(id: project_id) return if project.nil? || project.pending_delete? - uuid = try_obtain_lease_for(project_id) + uuid = lease_for(project_id).try_obtain if uuid ::Projects::HashedStorageMigrationService.new(project, logger).execute else false end rescue => ex - cancel_lease_for(project_id, uuid) + cancel_lease_for(project_id, uuid) if uuid raise ex end - private - - def try_obtain_lease_for(project_id) - Gitlab::ExclusiveLease.new(lease_key(project_id), timeout: LEASE_TIMEOUT).try_obtain + def lease_for(project_id) + Gitlab::ExclusiveLease.new(lease_key(project_id), timeout: LEASE_TIMEOUT) end + private + def lease_key(project_id) "project_migrate_hashed_storage_worker:#{project_id}" end |