Commit 357f9898 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Mayra Cabrera

Add OpenSSL::OpenSSLError to HTTP_ERRORS

Some services can raise OpenSSL::X509::CertificateError due
to an invalid SSL certificates, with OpenSSL::OpenSSLError
we can handle these errors.
parent 0cb361fe
...@@ -46,7 +46,7 @@ class DroneCiService < CiService ...@@ -46,7 +46,7 @@ class DroneCiService < CiService
end end
def commit_status(sha, ref) def commit_status(sha, ref)
with_reactive_cache(sha, ref) {|cached| cached[:commit_status] } with_reactive_cache(sha, ref) { |cached| cached[:commit_status] }
end end
def calculate_reactive_cache(sha, ref) def calculate_reactive_cache(sha, ref)
...@@ -68,7 +68,7 @@ class DroneCiService < CiService ...@@ -68,7 +68,7 @@ class DroneCiService < CiService
end end
{ commit_status: status } { commit_status: status }
rescue Errno::ECONNREFUSED rescue *Gitlab::HTTP::HTTP_ERRORS
{ commit_status: :error } { commit_status: :error }
end end
......
---
title: Fix invalid SSL certificate errors on Drone CI service
merge_request: 30422
author:
type: fixed
...@@ -10,9 +10,9 @@ module Gitlab ...@@ -10,9 +10,9 @@ module Gitlab
RedirectionTooDeep = Class.new(StandardError) RedirectionTooDeep = Class.new(StandardError)
HTTP_ERRORS = [ HTTP_ERRORS = [
SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, SocketError, OpenSSL::SSL::SSLError, OpenSSL::OpenSSLError,
Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError,
Gitlab::HTTP::RedirectionTooDeep Gitlab::HTTP::RedirectionTooDeep
].freeze ].freeze
......
...@@ -101,6 +101,15 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do ...@@ -101,6 +101,15 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
is_expected.to eq(:error) is_expected.to eq(:error)
end end
Gitlab::HTTP::HTTP_ERRORS.each do |http_error|
it "sets commit status to :error with a #{http_error.name} error" do
WebMock.stub_request(:get, commit_status_path)
.to_raise(http_error)
is_expected.to eq(:error)
end
end
{ {
"killed" => :canceled, "killed" => :canceled,
"failure" => :failed, "failure" => :failed,
......
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