1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Mark AWS metadata calls as idempotent

Mark calls to metadata services for AWS as idempotent. This means that excon
will retry request up to 3 times in case there is a (temporary) issue on the
metadata service.
This commit is contained in:
Michal Tekel 2016-12-12 16:30:10 +00:00
parent f622160e12
commit c61a2e39f3

View file

@ -21,15 +21,15 @@ module Fog
if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
connection = options[:connection] || Excon.new(CONTAINER_CREDENTIALS_HOST)
credential_path = options[:credential_path] || ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
role_data = connection.get(:path => credential_path, :expects => 200).body
role_data = connection.get(:path => credential_path, :idempotent => true, :expects => 200).body
connection = options[:metadata_connection] || Excon.new(INSTANCE_METADATA_HOST)
az_data = connection.get(:path => INSTANCE_METADATA_AZ, :expects => 200).body
az_data = connection.get(:path => INSTANCE_METADATA_AZ, :idempotent => true, :expects => 200).body
else
connection = options[:connection] || Excon.new(INSTANCE_METADATA_HOST)
role_name = connection.get(:path => INSTANCE_METADATA_PATH, :expects => 200).body
role_data = connection.get(:path => INSTANCE_METADATA_PATH+role_name, :expects => 200).body
az_data = connection.get(:path => INSTANCE_METADATA_AZ, :expects => 200).body
role_name = connection.get(:path => INSTANCE_METADATA_PATH, :idempotent => true, :expects => 200).body
role_data = connection.get(:path => INSTANCE_METADATA_PATH+role_name, :idempotent => true, :expects => 200).body
az_data = connection.get(:path => INSTANCE_METADATA_AZ, :idempotent => true, :expects => 200).body
end
region = az_data[0..-2] # get region from az