From 8674833d95226682e541593bc4adadec06347617 Mon Sep 17 00:00:00 2001 From: geemus Date: Fri, 3 Dec 2010 11:37:11 -0800 Subject: [PATCH] [aws|compute] work around eventual consistency errors --- lib/fog/aws/models/compute/servers.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/fog/aws/models/compute/servers.rb b/lib/fog/aws/models/compute/servers.rb index 173fbe524..2fad63ecc 100644 --- a/lib/fog/aws/models/compute/servers.rb +++ b/lib/fog/aws/models/compute/servers.rb @@ -98,7 +98,19 @@ module Fog end server.save - server.wait_for { ready? } + # eventual consistency sometimes means a delay before it appears + retries = 3 + begin + server.wait_for { ready? } + rescue Fog::Errors::Error => error + sleep(1) + retries -= 1 + if retries > 0 + retry + else + raise error + end + end server.setup(:key_data => [server.private_key]) server end