Skip to content

Commit

Permalink
Revert "make the changes more readable"
Browse files Browse the repository at this point in the history
This reverts commit f7dd849.
  • Loading branch information
anshrupani committed Apr 24, 2024
1 parent 1a6dad7 commit 913ec21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/bosh_azure_cpi/lib/cloud/azure/restapi/azure_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,8 @@ class AzureClient # rubocop:todo Metrics/ClassLength

def initialize(azure_config, logger)
@logger = logger
@azure_config = azure_config

# Allow Net::HTTP to support instance variable names via ssl_options
(Net::HTTP::SSL_IVNAMES << :@ssl_options).uniq!
(Net::HTTP::SSL_ATTRIBUTES << :options).uniq!

Net::HTTP.class_eval do
attr_accessor :ssl_options
end
@azure_config = azure_config
end

# Common
Expand Down Expand Up @@ -2260,9 +2253,16 @@ def redact_credentials_in_response_body(body)

# @return [Net::HTTP]
def http(uri, use_ssl = true)
(Net::HTTP::SSL_IVNAMES << :@ssl_options).uniq!
(Net::HTTP::SSL_ATTRIBUTES << :options).uniq!

Net::HTTP.class_eval do
attr_accessor :ssl_options
end
options_mask = OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true && use_ssl
http.ssl_options = OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF if OpenSSL::SSL.const_defined? :OP_IGNORE_UNEXPECTED_EOF # Does not exist if using openssl 1.x
http.ssl_options = options_mask
if @azure_config.environment == ENVIRONMENT_AZURESTACK && uri.host.include?(@azure_config.azure_stack.domain)
# The CA cert is only specified for the requests to AzureStack domain. If specified for other domains, the request will fail.
http.ca_file = get_ca_cert_path
Expand Down Expand Up @@ -2469,7 +2469,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) || e.inspect.include?(ERROR_OPENSSL_EOF_READ))
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
3 changes: 1 addition & 2 deletions src/bosh_azure_cpi/lib/cloud/azure/storage/blob_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +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) || error_message.include?(Bosh::AzureCloud::Helpers::ERROR_OPENSSL_EOF_READ)
# Retry on "SSL_read: unexpected eof while reading" error (OpenSSL::SSL::SSLError)
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

0 comments on commit 913ec21

Please sign in to comment.