|
Here's how I would implement this:
1) Add new boolean flag "fallbackToOndemand" for spot instances.
2) When lauching instances, if "fallbackToOndemand" do a spot price check to see whether to use spot or ondemand, and call the appropriate class. I believe this is in SlaveTemplate class , provision() method.
3) EC2RetentionStrategy is responsible for killing instances. Here you'll have to do periodic spot price check for any "fallback ondemand" instances to see if the spot price has come back down, in which case you can kill the ondemand and allow a spot to be restarted in it's place (it will pass the check in #2)
4) You may want to add some mechanism to prevent constant toggling between ondemand and fallback. At least you should not change more frequently that 1 hour, because you pay for a minimum of 1 hour usage even if you use less than one hour.
|