Commit 53242397 authored by Marius Bobin's avatar Marius Bobin

Use Gitlab::HTTP.try_get to calculate cache for DroneCi

parent cf586958
......@@ -50,10 +50,12 @@ class DroneCiService < CiService
end
def calculate_reactive_cache(sha, ref)
response = Gitlab::HTTP.get(commit_status_path(sha, ref), verify: enable_ssl_verification)
response = Gitlab::HTTP.try_get(commit_status_path(sha, ref),
verify: enable_ssl_verification,
extra_log_info: { project_id: project_id })
status =
if response.code == 200 && response['status']
if response && response.code == 200 && response['status']
case response['status']
when 'killed'
:canceled
......@@ -68,8 +70,6 @@ class DroneCiService < CiService
end
{ commit_status: status }
rescue *Gitlab::HTTP::HTTP_ERRORS
{ commit_status: :error }
end
def build_page(sha, ref)
......
......@@ -106,6 +106,10 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
WebMock.stub_request(:get, commit_status_path)
.to_raise(http_error)
expect(Gitlab::ErrorTracking)
.to receive(:log_exception)
.with(instance_of(http_error), project_id: project.id)
is_expected.to eq(:error)
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