Commit 713d19c2 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'jc-praefect-service' into 'master'

Adding PraefectInfoService

See merge request gitlab-org/gitlab!28046
parents 930acdbd a6e438f7
...@@ -944,6 +944,10 @@ module Gitlab ...@@ -944,6 +944,10 @@ module Gitlab
Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid) Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid)
end end
def praefect_info_client
@praefect_info_client ||= Gitlab::GitalyClient::PraefectInfoService.new(self)
end
def clean_stale_repository_files def clean_stale_repository_files
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_repository_client.cleanup if exists? gitaly_repository_client.cleanup if exists?
...@@ -1019,6 +1023,12 @@ module Gitlab ...@@ -1019,6 +1023,12 @@ module Gitlab
raise NoRepository # Guard against data races. raise NoRepository # Guard against data races.
end end
def replicas
wrapped_gitaly_errors do
praefect_info_client.replicas
end
end
private private
def empty_diff_stats def empty_diff_stats
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class PraefectInfoService
def initialize(repository)
@repository = repository
@gitaly_repo = repository.gitaly_repository
@storage = repository.storage
end
def replicas
request = Gitaly::RepositoryReplicasRequest.new(repository: @gitaly_repo)
GitalyClient.call(@storage, :praefect_info_service, :repository_replicas, request, timeout: GitalyClient.fast_timeout)
end
end
end
end
...@@ -1919,6 +1919,15 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1919,6 +1919,15 @@ describe Gitlab::Git::Repository, :seed_helper do
end end
end end
describe '#replicas', :praefect do
it 'gets the replica checksum through praefect' do
resp = repository.replicas
expect(resp.replicas).to be_empty
expect(resp.primary.checksum).to eq(repository.checksum)
end
end
describe '#clean_stale_repository_files' do describe '#clean_stale_repository_files' do
let(:worktree_id) { 'rebase-1' } let(:worktree_id) { 'rebase-1' }
let(:gitlab_worktree_path) { File.join(repository_path, 'gitlab-worktree', worktree_id) } let(:gitlab_worktree_path) { File.join(repository_path, 'gitlab-worktree', worktree_id) }
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::PraefectInfoService do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:gitaly_repository) { repository.gitaly_repository }
let(:client) { described_class.new(repository) }
describe '#repository_replicas', :praefect do
it 'sends an RPC request' do
request = Gitaly::RepositoryReplicasRequest.new(repository: gitaly_repository)
expect_any_instance_of(Gitaly::PraefectInfoService::Stub).to receive(:repository_replicas).with(request, kind_of(Hash))
client.replicas
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