Skip to content

Commit

Permalink
retry CPI calls in case of SSL_read errors as well
Browse files Browse the repository at this point in the history
  • Loading branch information
anshrupani committed Feb 9, 2024
1 parent ba70607 commit f291148
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/restapi/azure_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ def http_get_response_with_network_retry(http_handler, request)
end
raise e
rescue OpenSSL::SSL::SSLError, OpenSSL::X509::StoreError => e
if retry_count < AZURE_MAX_RETRY_COUNT && e.inspect.include?(ERROR_OPENSSL_RESET)
if retry_count < AZURE_MAX_RETRY_COUNT && [ERROR_OPENSSL_RESET, ERROR_OPENSSL_EOF_READ].any? { |error| e.inspect.include?(error) }
retry_count += 1
@logger.warn(format(error_msg_format, retry_count: retry_count, retry_after: retry_after, error: e.class.name))
sleep(retry_after)
Expand Down
2 changes: 1 addition & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/storage/blob_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def apply_retry_policy(retry_data)
if retry_data[:error].is_a?(OpenSSL::SSL::SSLError) || retry_data[:error].is_a?(OpenSSL::X509::StoreError)
error_message = retry_data[:error].inspect

if error_message.include?(Bosh::AzureCloud::Helpers::ERROR_OPENSSL_RESET)
if [Bosh::AzureCloud::Helpers::ERROR_OPENSSL_RESET, Bosh::AzureCloud::Helpers:ERROR_OPENSSL_EOF_READ].any? { |error| error_message.include?(error) }
# Retry on "Connection reset by peer - SSL_connect" error (OpenSSL::SSL::SSLError, OpenSSL::X509::StoreError)
# https://github.com/cloudfoundry/bosh-azure-cpi-release/issues/234
retry_data[:retryable] = true
Expand Down
1 change: 1 addition & 0 deletions src/bosh_azure_cpi/lib/cloud/azure/utils/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ module Helpers

# REST Connection Errors
ERROR_OPENSSL_RESET = 'SSL_connect'
ERROR_OPENSSL_EOF_READ = 'SSL_read'
ERROR_SOCKET_UNKNOWN_HOSTNAME = 'Hostname not known'
ERROR_CONNECTION_REFUSED = 'Connection refused'

Expand Down

0 comments on commit f291148

Please sign in to comment.