Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Spot cleanup #64

merged 4 commits into from

2 participants


More bug fixes:

  1. Fixed extra -- in metadata names of machines when no project is specified.
  2. Spot requests are cancelled at EC2 when the user gives up waiting for them to be fulfilled.

I'd probably leave this pull request open until we figure out the size/AZ config bug from the other pull request. That way, if we need to, I can add it as more commits to this pull request before you merge it in to master.


No worries. We're actively using this branch now so we're not blocked by this. That said, in using it, a coworker of mine found a bug where machines created via config without a project are not picked up from SDB once a project key is added to the config. I'll look at that tonight.

@Fluxx Fluxx Remove project name from metadata lookup if the project name is empty…
…. This preserves backwards compatability with Rudy projects that are created without a project set.

Fixed the bug. Now when looking up metadata, we remove the project name from the default SDB criteria. This means that metadata entries created without a project show up if they were created before the project key existed.

@delano delano merged commit 52627b6 into solutious:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 2, 2011
  1. @Fluxx

    Fix bug where extra dash (-) was included in metadata name for machin…

    Fluxx authored
    …es when no project name is given.
  2. @Fluxx

    When waiting for a spot request is cancelled by the user, cancel the …

    Fluxx authored
    …spot request itself at EC2.
Commits on Jun 3, 2011
  1. @Fluxx
Commits on Jun 11, 2011
  1. @Fluxx

    Remove project name from metadata lookup if the project name is empty…

    Fluxx authored
    …. This preserves backwards compatability with Rudy projects that are created without a project set.
This page is out of date. Refresh to see the latest.
5 lib/rudy/aws/ec2/spot_request.rb
@@ -89,6 +89,11 @@ def self.from_hash(hash)
+ def cancel(requests)
+ opts = requests ? {:spot_instance_request_id =>} : {}
+ Rudy::AWS::EC2.execute_request({}) { @@ec2.cancel_spot_instance_requests(opts) }
+ end
2  lib/rudy/exceptions.rb
@@ -68,5 +68,7 @@ class UnsupportedOS < Rudy::Error; end
class NotImplemented < Rudy::Error; end
+ class SpotRequestCancelled < Rudy::Error; end
7 lib/rudy/metadata.rb
@@ -88,6 +88,9 @@ def{})
# Generates a default criteria for all metadata based on
# region, zone, environment, and role. If a position has
# been specified in the globals it will also be included.
+ # The project name will also be removed if empty, to
+ # maintain backwards compatability with metadata entries
+ # that do not contain a projet field.
# * +rtype+ is the record type. One of: m, disk, or back.
# * +fields+ replaces and adds values to this criteria
# * +less+ removes keys from the default criteria.
@@ -102,6 +105,7 @@ def self.build_criteria(rtype, fields={}, less=[])
mixer =
criteria = Hash[*mixer].merge(fields)
criteria.reject! { |n,v| less.member?(n) }
+ criteria.delete(:project) if criteria[:project].to_s.empty?
Rudy::Huxtable.ld "CRITERIA: #{criteria.inspect}"
@@ -182,7 +186,8 @@ def initialize(rtype, opts={})
def name(*other)
- parts = [@rtype, @zone, @project, @environment, @role, @position, *other]
+ project = (@project.is_a?(Array) && @project.first.empty?) ? nil : @project
+ parts = [@rtype, @zone, project, @environment, @role, @position, *other]
parts.compact.flatten.join Rudy::DELIM
3  lib/rudy/routines/handlers/spot_request.rb
@@ -21,6 +21,9 @@ def create
request = Rudy::AWS::EC2::SpotRequests.create(opts)
raise NoMachines unless wait_for_fulfillment_of(request)
+ rescue NoMachines
+ Rudy::AWS::EC2::SpotRequests.cancel(request)
+ raise SpotRequestCancelled
def wait_for_fulfillment_of(spot_requests)
Something went wrong with that request. Please try again.