Permalink
Browse files

Better and more successful way to wait for spot instances to be fulfi…

…lled.
  • Loading branch information...
Fluxx committed May 30, 2011
1 parent 78955b9 commit c5b131d8f3947e5ef4359d83f2158a85e0069aa9
Showing with 5 additions and 6 deletions.
  1. +1 −2 lib/rudy/aws/ec2/spot_request.rb
  2. +4 −4 lib/rudy/routines/handlers/spot_request.rb
@@ -68,8 +68,7 @@ def list(requests = nil)
end
def fulfilled?(requests)
- fetched = list(requests)
- fetched if fetched.all? { |r| r.fulfilled? }
+ list(requests).all? { |r| r.fulfilled? }
end
def self.from_hash(hash)
@@ -18,14 +18,14 @@ def create
:keypair => root_keypairname
}
- Rudy::AWS::EC2::SpotRequests.create(opts).tap do |request|
- wait_for_fulfillment_of(request)
- end
+ request = Rudy::AWS::EC2::SpotRequests.create(opts)
+ wait_for_fulfillment_of(request)
+ Rudy::AWS::EC2::SpotRequests.list(request)
end
def wait_for_fulfillment_of(spot_requests)
msg = "Waiting for #{spot_requests.length} spot requests to be fulfilled"
- Rudy::Utils.waiter(2, 90, Rudy::Huxtable.logger, msg, 2) {
+ Rudy::Utils.waiter(2, 180, Rudy::Huxtable.logger, msg, 2) {
Rudy::AWS::EC2::SpotRequests.fulfilled?(spot_requests)
}
end

0 comments on commit c5b131d

Please sign in to comment.