summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-10 15:08:54 -0700
committerStan Hu <stanhu@gmail.com>2018-07-10 15:11:10 -0700
commit0c1eebe24c9717da10c6335b91273dbb73061ff8 (patch)
tree8e2b1239a9212f9151f47c7bb27c3fa1e6e5bc70
parent255db3d59792e9bac92f4327b4e324e2bd32810a (diff)
downloadgitlab-ce-0c1eebe24c9717da10c6335b91273dbb73061ff8.tar.gz
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
-rw-r--r--app/workers/git_garbage_collect_worker.rb4
-rw-r--r--spec/workers/git_garbage_collect_worker_spec.rb6
2 files changed, 8 insertions, 2 deletions
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb
index fd49bc18161..2d381c6fd6c 100644
--- a/app/workers/git_garbage_collect_worker.rb
+++ b/app/workers/git_garbage_collect_worker.rb
@@ -65,10 +65,10 @@ class GitGarbageCollectWorker
client.repack_incremental
end
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)
rescue GRPC::BadStatus => e
- Gitlab::GitLogger.error("#{method} failed:\n#{e}")
+ Gitlab::GitLogger.error("#{__method__} failed:\n#{e}")
raise Gitlab::Git::CommandError.new(e)
end
diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb
index e39dec556fc..d5808e21271 100644
--- a/spec/workers/git_garbage_collect_worker_spec.rb
+++ b/spec/workers/git_garbage_collect_worker_spec.rb
@@ -27,6 +27,12 @@ describe GitGarbageCollectWorker do
subject.perform(project.id, :gc, lease_key, lease_uuid)
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
context 'with different lease than the active one' do