Skip to content

Commit

Permalink
Catch OpenSSL::SSL::SSLError exceptions when ...
Browse files Browse the repository at this point in the history
... reporting back to the SCM/CI

This exception is thrown by httparty, the rubygem used by the Gitlab
rubygem. Therefore, we catch this exception only when trying to connect
to a Gitlab instance.
  • Loading branch information
eduardoj committed Oct 26, 2023
1 parent 334b9ec commit ffcda0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/app/services/gitlab_status_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call
@workflow_run.save_scm_report_success(request_context)
RabbitmqBus.send_to_bus('metrics', "scm_status_report,status=success,scm=#{@event_subscription_payload[:scm]} value=1")
end
rescue Gitlab::Error::Error => e
rescue Gitlab::Error::Error, OpenSSL::SSL::SSLError => e
rescue_with_handler(e) || raise(e)
RabbitmqBus.send_to_bus('metrics', "scm_status_report,status=fail,scm=#{@event_subscription_payload[:scm]},exception=#{e.class} value=1") if @workflow_run.present?
end
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/services/scm_exception_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SCMExceptionHandler
end

rescue_from Gitlab::Error::BadGateway,
Gitlab::Error::BadRequest,
Gitlab::Error::Conflict,
Gitlab::Error::Forbidden,
Gitlab::Error::InternalServerError,
Expand All @@ -38,7 +39,7 @@ class SCMExceptionHandler
Gitlab::Error::ServiceUnavailable,
Gitlab::Error::TooManyRequests,
Gitlab::Error::Unauthorized,
Gitlab::Error::BadRequest do |exception|
OpenSSL::SSL::SSLError do |exception|
log_to_workflow_run(exception, 'GitLab') if @workflow_run.present?
end

Expand Down

0 comments on commit ffcda0a

Please sign in to comment.