Commit ba41cbc9 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch...

Merge branch '34722-dashboard-projectscontroller-should-tolerate-single-gitaly-node-failure' into 'master'

Fix 503 errors caused by Gitaly failures during project_icon lookup

See merge request gitlab-org/gitlab!23930
parents eddfc137 c215c6f6
...@@ -122,6 +122,13 @@ module AvatarsHelper ...@@ -122,6 +122,13 @@ module AvatarsHelper
else else
source_identicon(source, options) source_identicon(source, options)
end end
rescue GRPC::Unavailable, GRPC::DeadlineExceeded => e
# Handle Gitaly connection issues gracefully
Gitlab::ErrorTracking
.track_exception(e, source_type: source.class.name, source_id: source.id)
source_identicon(source, options)
end end
def source_identicon(source, options = {}) def source_identicon(source, options = {})
......
---
title: Fix 503 errors caused by Gitaly failures during project_icon lookup
merge_request: 23930
author:
type: fixed
...@@ -22,15 +22,41 @@ describe AvatarsHelper do ...@@ -22,15 +22,41 @@ describe AvatarsHelper do
end end
end end
context 'when providing a project' do shared_examples 'Gitaly exception handling' do
it_behaves_like 'resource with a default avatar', 'project' do before do
let(:resource) { create(:project, name: 'foo') } allow(resource).to receive(:avatar_url).and_raise(error_class)
let(:helper_args) { [resource] }
end end
it 'handles Gitaly exception gracefully' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(error_class), source_type: 'Project', source_id: resource.id
)
expect { project_icon(resource) }.not_to raise_error
end
it_behaves_like 'resource with a default avatar', 'project'
end
context 'when providing a project' do
let(:helper_args) { [resource] }
let(:resource) { create(:project, name: 'foo') }
it_behaves_like 'resource with a default avatar', 'project'
it_behaves_like 'resource with a custom avatar', 'project' do it_behaves_like 'resource with a custom avatar', 'project' do
let(:resource) { create(:project, :public, avatar: File.open(uploaded_image_temp_path)) } let(:resource) { create(:project, :public, avatar: File.open(uploaded_image_temp_path)) }
let(:helper_args) { [resource] } end
context 'when Gitaly is unavailable' do
let(:error_class) { GRPC::Unavailable }
include_examples 'Gitaly exception handling'
end
context 'when Gitaly request is taking too long' do
let(:error_class) { GRPC::DeadlineExceeded }
include_examples 'Gitaly exception handling'
end 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