Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Integrate spot instances in to the startup routine.

  • Loading branch information...
commit fdddb47b2d52546104f5a4ed5632991afe42e3fb 1 parent c5b131d
@Fluxx Fluxx authored
Showing with 23 additions and 1 deletion.
  1. +14 −0 lib/rudy/machines.rb
  2. +9 −1 lib/rudy/routines/startup.rb
View
14 lib/rudy/machines.rb
@@ -63,6 +63,20 @@ def create(size=nil)
group
end
+ def from_spot_request(request)
+ instances = Rudy::AWS::EC2::Instances.list(:running, request.map(&:instid))
+
+ current_machine_positions.zip(instances).map do |position, instance|
+ Rudy::Machine.new(position).tap do |machine|
+ machine.instid = instance.awsid
+ machine.created = machine.started = Time.now
+ machine.state = instance.state
+ machine.save
+ sleep 1 # Eventual consistency in SimpleDB
+ end
+ end
+ end
+
def restart
group = list
raise MachineGroupNotRunning, current_machine_group if group.nil?
View
10 lib/rudy/routines/startup.rb
@@ -58,7 +58,15 @@ def execute
# we'll just grab the list of machines in this group.
# NOTE: Expect errors if there are no machines.
Rudy::Routines.rescue {
- @machines = run? ? Rudy::Machines.create : Rudy::Machines.list
+ @machines = if !run?
+ Rudy::Machines.list
+ elsif Rudy::Routines::Handlers::SpotRequest.needed?
+ request = Rudy::Routines::Handlers::SpotRequest.create
+ Rudy::Machines.from_spot_request(request)
+ else
+ Rudy::Machines.create
+ end
+
@@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
}
Please sign in to comment.
Something went wrong with that request. Please try again.