diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-07-05 21:05:24 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-07-05 21:05:24 +0000 |
commit | 357f9898d586a0310a1111c0c5763c8707c4fb02 (patch) | |
tree | 4c68a22798b5d863d849e44e679e09cf32b1e9ef | |
parent | 0cb361fe8f4bd06d9f42e3e7f797631acb4f8d60 (diff) | |
download | gitlab-ce-357f9898d586a0310a1111c0c5763c8707c4fb02.tar.gz |
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.
-rw-r--r-- | app/models/project_services/drone_ci_service.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/64176-fix-error-handling.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/http.rb | 6 | ||||
-rw-r--r-- | spec/models/project_services/drone_ci_service_spec.rb | 9 |
4 files changed, 19 insertions, 5 deletions
diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb index dbdc8345c93..d2660051343 100644 --- a/app/models/project_services/drone_ci_service.rb +++ b/app/models/project_services/drone_ci_service.rb @@ -46,7 +46,7 @@ class DroneCiService < CiService end def commit_status(sha, ref) - with_reactive_cache(sha, ref) {|cached| cached[:commit_status] } + with_reactive_cache(sha, ref) { |cached| cached[:commit_status] } end def calculate_reactive_cache(sha, ref) @@ -68,7 +68,7 @@ class DroneCiService < CiService end { commit_status: status } - rescue Errno::ECONNREFUSED + rescue *Gitlab::HTTP::HTTP_ERRORS { commit_status: :error } end diff --git a/changelogs/unreleased/64176-fix-error-handling.yml b/changelogs/unreleased/64176-fix-error-handling.yml new file mode 100644 index 00000000000..e7a9a5897ae --- /dev/null +++ b/changelogs/unreleased/64176-fix-error-handling.yml @@ -0,0 +1,5 @@ +--- +title: Fix invalid SSL certificate errors on Drone CI service +merge_request: 30422 +author: +type: fixed diff --git a/lib/gitlab/http.rb b/lib/gitlab/http.rb index db2b4dde244..58bce613a98 100644 --- a/lib/gitlab/http.rb +++ b/lib/gitlab/http.rb @@ -10,9 +10,9 @@ module Gitlab RedirectionTooDeep = Class.new(StandardError) HTTP_ERRORS = [ - SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, - Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, - Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, + SocketError, OpenSSL::SSL::SSLError, OpenSSL::OpenSSLError, + Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, + Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep ].freeze diff --git a/spec/models/project_services/drone_ci_service_spec.rb b/spec/models/project_services/drone_ci_service_spec.rb index 22df19d943f..a771d1bf27f 100644 --- a/spec/models/project_services/drone_ci_service_spec.rb +++ b/spec/models/project_services/drone_ci_service_spec.rb @@ -101,6 +101,15 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do is_expected.to eq(:error) 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, "failure" => :failed, |