Commit 0c1eebe2 authored by Stan Hu's avatar Stan Hu

Fix ArgumentError in GitGarbageCollectWorker Sidekiq job

When the Gitaly call failed, the exception handling failed
because `method` is expected to have a parameter.

Closes #49096
parent 255db3d5
...@@ -65,10 +65,10 @@ class GitGarbageCollectWorker ...@@ -65,10 +65,10 @@ class GitGarbageCollectWorker
client.repack_incremental client.repack_incremental
end end
rescue GRPC::NotFound => e rescue GRPC::NotFound => e
Gitlab::GitLogger.error("#{method} failed:\nRepository not found") Gitlab::GitLogger.error("#{__method__} failed:\nRepository not found")
raise Gitlab::Git::Repository::NoRepository.new(e) raise Gitlab::Git::Repository::NoRepository.new(e)
rescue GRPC::BadStatus => e rescue GRPC::BadStatus => e
Gitlab::GitLogger.error("#{method} failed:\n#{e}") Gitlab::GitLogger.error("#{__method__} failed:\n#{e}")
raise Gitlab::Git::CommandError.new(e) raise Gitlab::Git::CommandError.new(e)
end end
......
...@@ -27,6 +27,12 @@ describe GitGarbageCollectWorker do ...@@ -27,6 +27,12 @@ describe GitGarbageCollectWorker do
subject.perform(project.id, :gc, lease_key, lease_uuid) subject.perform(project.id, :gc, lease_key, lease_uuid)
end end
it 'handles gRPC errors' do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:garbage_collect).and_raise(GRPC::NotFound)
expect { subject.perform(project.id, :gc, lease_key, lease_uuid) }.to raise_exception(Gitlab::Git::Repository::NoRepository)
end
end end
context 'with different lease than the active one' do context 'with different lease than the active one' do
......
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