Commit 0e2b2268 authored by Nick Thomas's avatar Nick Thomas

Merge branch...

Merge branch '4957-projectsyncworker-should-skip-projects-that-have-a-broken-gitaly-shard' into 'master'

Resolve "ProjectSyncWorker should skip projects that have a broken Gitaly shard"

Closes #4957

See merge request gitlab-org/gitlab-ee!5514
parents b2370679 9c0af147
......@@ -21,6 +21,12 @@ module Geo
return
end
shard_name = project.repository_storage
unless Gitlab::Geo::ShardHealthCache.healthy_shard?(shard_name)
log_error("Project shard '#{shard_name}' is unhealthy, skipping syncing", project_id: project_id)
return
end
mark_disabled_wiki_as_synced(registry)
Geo::RepositorySyncService.new(project).execute if registry.repository_sync_due?(scheduled_time)
......
---
title: Prevent Geo from unnecessarily syncing expired CI job artifacts
merge_request:
author:
type: performance
......@@ -3,10 +3,17 @@ require 'rails_helper'
RSpec.describe Geo::ProjectSyncWorker do
describe '#perform' do
let(:project) { create(:project) }
let(:project_with_broken_storage) { create(:project, :broken_storage) }
let(:repository_sync_service) { spy }
let(:wiki_sync_service) { spy }
before do
allow(Gitlab::Geo::ShardHealthCache).to receive(:healthy_shard?)
.with(project.repository_storage).once.and_return(true)
allow(Gitlab::Geo::ShardHealthCache).to receive(:healthy_shard?)
.with(project_with_broken_storage.repository_storage).once.and_return(false)
allow(Geo::RepositorySyncService).to receive(:new)
.with(instance_of(Project)).once.and_return(repository_sync_service)
......@@ -22,6 +29,16 @@ RSpec.describe Geo::ProjectSyncWorker do
end
end
context 'when the shard associated to the project is unhealthy' do
it 'logs an error and returns' do
expect(subject).to receive(:log_error).with("Project shard '#{project_with_broken_storage.repository_storage}' is unhealthy, skipping syncing", project_id: project_with_broken_storage.id)
expect(repository_sync_service).not_to receive(:execute)
expect(wiki_sync_service).not_to receive(:execute)
subject.perform(project_with_broken_storage.id, Time.now)
end
end
context 'when project repositories has never been synced' do
it 'performs Geo::RepositorySyncService for the given project' do
subject.perform(project.id, Time.now)
......
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