Commit a4ed1e16 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '7722-geo-repository-verification-lease-key' into 'master'

Resolve "Geo::RepositoryVerification::Secondary::ShardWorker lease key is not namespaced by shard name"

Closes #7722

See merge request gitlab-org/gitlab-ee!7474
parents dde69913 79c6a1a7
......@@ -14,17 +14,17 @@ module Geo
super()
end
# We need a custom key here since we are running one worker per shard
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
private
def worker_metadata
{ shard: shard_name }
end
# We need a custom key here since we are running one worker per shard
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
def max_capacity
current_node.verification_max_capacity
end
......
......@@ -14,6 +14,10 @@ module Geo
super()
end
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
private
def worker_metadata
......
---
title: 'Geo: repository shard verification job should have unique lease keys per shard
name'
merge_request: 7474
author:
type: fixed
......@@ -19,6 +19,14 @@ describe Geo::RepositoryVerification::Primary::ShardWorker, :postgresql, :clean_
Gitlab::ShardHealthCache.update([shard_name])
end
context 'shard worker scheduler' do
it 'acquires lock namespacing it per shard name' do
subject.perform(shard_name)
expect(subject.lease_key).to include(shard_name)
end
end
it 'performs Geo::RepositoryVerification::Primary::SingleWorker for each project' do
create_list(:project, 2)
......
......@@ -22,7 +22,15 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
Gitlab::ShardHealthCache.update([shard_name])
end
it 'schedules job for each project' do
context 'shard worker scheduler' do
it 'acquires lock namespacing it per shard name' do
subject.perform(shard_name)
expect(subject.lease_key).to include(shard_name)
end
end
it 'schedule a job for each project' do
other_project = create(:project)
create(:repository_state, :repository_verified, project: project)
create(:repository_state, :repository_verified, project: other_project)
......@@ -34,7 +42,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name)
end
it 'schedules job for projects missing repository verification' do
it 'schedule jobs for projects missing repository verification' do
create(:repository_state, :repository_verified, :wiki_verified, project: project)
missing_repository_verification = create(:geo_project_registry, :synced, :wiki_verified, project: project)
......@@ -43,7 +51,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name)
end
it 'schedules job for projects missing wiki verification' do
it 'schedule jobs for projects missing wiki verification' do
create(:repository_state, :repository_verified, :wiki_verified, project: project)
missing_wiki_verification = create(:geo_project_registry, :synced, :repository_verified, project: project)
......
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