Skip to content

Commit ed33cf3

Browse files
Felipe AmaranteKatyal
authored andcommitted
Adding exponential backoff at install bin which downloads Agent files from S3
cr https://code.amazon.com/reviews/CR-2000139
1 parent 8c786b2 commit ed33cf3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

bin/install

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,24 @@ EOF
243243
uri = get_s3_uri(region, bucket, key)
244244

245245
# stream package file to disk
246+
retries ||= 0
247+
exceptions = [OpenURI::HTTPError, OpenSSL::SSL::SSLError]
246248
begin
247249
uri.open(:ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER, :redirect => true, :read_timeout => 120, :proxy => @http_proxy) do |s3|
248-
package_file.write(s3.read)
250+
package_file.write(s3.read)
251+
end
252+
rescue *exceptions => e
253+
@log.error("Could not find package to download at '#{uri.to_s}' - Retrying... Attempt: '#{retries.to_s}'")
254+
if (retries < 5)
255+
sleep 2 ** retries
256+
retries += 1
257+
retry
258+
else
259+
@log.error("Could not download CodeDeploy Agent Package. Exiting Install script.")
260+
exit(1)
249261
end
250-
rescue OpenURI::HTTPError => e
251-
@log.error("Could not find package to download at '#{uri.to_s}'")
252-
exit(1)
253262
end
254-
end
263+
end
255264

256265
def get_version_file_from_s3(region, bucket, key)
257266
@log.info("Downloading version file from bucket #{bucket} and key #{key}...")

0 commit comments

Comments
 (0)