From c61a2e39f3b9fe81ecc436835b7f35d69396f3db Mon Sep 17 00:00:00 2001 From: Michal Tekel Date: Mon, 12 Dec 2016 16:30:10 +0000 Subject: [PATCH] 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. --- lib/fog/aws/credential_fetcher.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fog/aws/credential_fetcher.rb b/lib/fog/aws/credential_fetcher.rb index 132ef92bb..90b3d0629 100644 --- a/lib/fog/aws/credential_fetcher.rb +++ b/lib/fog/aws/credential_fetcher.rb @@ -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