Commit c3df27ac authored by Vasilii Iakliushin's avatar Vasilii Iakliushin Committed by Luke Duncalfe

Don't trigger a sentry error for Gitaly exceptions

**Problem**

We add a Sentry error for cases when Gitaly is not available. We
already handle this exception, so Sentry tracking is not necessary.

We return a 200 response when the Gitaly is not available. It is
confusing and makes it difficult to track unsuccessful requests.

**Solution**

* Respond with 503 error
* Don't log exceptions in Sentry

Changelog: changed
parent 81f5f80f
......@@ -34,11 +34,9 @@ class Projects::BranchesController < Projects::ApplicationController
Gitlab::GitalyClient.allow_n_plus_1_calls do
render
end
rescue Gitlab::Git::CommandError => e
Gitlab::ErrorTracking.track_exception(e)
rescue Gitlab::Git::CommandError
@gitaly_unavailable = true
render
render status: :service_unavailable
end
format.json do
branches = BranchesFinder.new(@repository, params).execute
......
......@@ -688,21 +688,23 @@ RSpec.describe Projects::BranchesController do
end
context 'when gitaly is not available' do
let(:request) { get :index, format: :html, params: { namespace_id: project.namespace, project_id: project } }
before do
allow_next_instance_of(Gitlab::GitalyClient::RefService) do |ref_service|
allow(ref_service).to receive(:local_branches).and_raise(GRPC::DeadlineExceeded)
end
get :index, format: :html, params: {
namespace_id: project.namespace, project_id: project
}
end
it 'returns with a status 200' do
expect(response).to have_gitlab_http_status(:ok)
it 'returns with a status 503' do
request
expect(response).to have_gitlab_http_status(:service_unavailable)
end
it 'sets gitaly_unavailable variable' do
request
expect(assigns[:gitaly_unavailable]).to be_truthy
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