Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Support Spot Instances #32

Open
iangcarroll opened this issue Apr 3, 2013 · 59 comments · May be fixed by #514
Open

Support Spot Instances #32

iangcarroll opened this issue Apr 3, 2013 · 59 comments · May be fixed by #514

Comments

@iangcarroll
Copy link

Testing costs could be lowered from 3 cents an hour to .003 cents an hour.

Edited to remove development from issue, tralamazza has a point

@tralamazza
Copy link
Collaborator

could be nice, but spot instances might be killed at any moment, good for fault tolerant tasks

@kamalmarhubi
Copy link
Contributor

I have this on my mind as well. Not for development per se, but as a way to spin up a temporary big box at low cost without all this ec2rsi -t blah -f blah -p blah stuff, and without having to fit all the setup in just one file.

I'd be willing to take a stab at implementation but I need to learn a bit more about Vagrant's architecture. In particular, it would be preferable to me to specify the price limit and instance type on the command line, but I don't know if providers can specify their own command line options.

@mitchellh
Copy link
Owner

I think this would be perfect for Vagrant-style development where creating a dev environment can be "cheap"

I'd love to look into this.

@tralamazza
Copy link
Collaborator

I looked into spot instance requests, they are extremely slow (5 to 10 minutes sometimes). I have a prototype implementation which records a spot request id in the data_dir. I don't know if that is the correct approach. Maybe the simplest would be to implement separate commands for that.

@kamalmarhubi
Copy link
Contributor

Oh great! I was going to look into this later this week because it's something I really want: an easier interface for one-off spot instances to do big crunching. Can you throw your code up into a branch on your fork?

@kamalmarhubi
Copy link
Contributor

@tralamazza Bumpity bump! Do you think you'll keep going with yours?

@alexgorbatchev
Copy link

👍

@tralamazza
Copy link
Collaborator

I will push my work here https://github.com/tralamazza/vagrant-aws/tree/spot_commands

@kamalmarhubi
Copy link
Contributor

Thanks! I'll take a look when I get some time. Are you still working on it?

@tralamazza
Copy link
Collaborator

I have a working version here.
To use it you must specify the spot_max_price and set spot_instance to true.

# ...
aws.region_config "eu-west-1" do |region|
  # ...
  region.spot_instance = true
  region.spot_max_price = "0.2"
end
$> vagrant up --provider=aws

Note: these are one-off spot requests.
Note2: this branch also contains PRs #31 and #93

@wutali
Copy link

wutali commented Aug 27, 2013

+1

@mitchellh Do you have a plan to merge this feature from the @tralamazza 's branch?
If there is something to do, I wanna contribute it.

@nabeken
Copy link

nabeken commented Sep 26, 2013

👍

@tralamazza
Copy link
Collaborator

Anyone tried this patch? Any feedback?

@nabeken
Copy link

nabeken commented Oct 11, 2013

@tralamazza I tried your changes and it works well. I fixed a minor problem at nabeken@86ff6b6

A parallel acceptance test with a combination of vagrant-aws + spot instance + Jenkins dramatically accelerates the tests and also keeps down costs:satisfied:

@tralamazza
Copy link
Collaborator

@nabeken nice! thanks.

@spullara
Copy link

spullara commented Jan 4, 2014

Vagrant + Spot instances would be great!

@jfmwz
Copy link

jfmwz commented Jan 7, 2014

I would like to get it

@agarwlGaurav
Copy link

Implementing it will be very useful.

@yuku
Copy link

yuku commented May 14, 2014

👍

@varju
Copy link

varju commented May 14, 2014

Building on the work @nabeken did, I've merged in the latest changes from master at varju@0bb9f27

@maccman
Copy link

maccman commented May 21, 2014

I'd love for this to get merged. It's incredibly useful and will save me a lot of money! 👍

nabeken added a commit to nabeken/vagrant-aws that referenced this issue Jul 29, 2014
rebased on current 0.5.0 with original work at mitchellh#32
@nabeken
Copy link

nabeken commented Jul 31, 2014

FYI: I've rebased spot instance support on current master at https://github.com/nabeken/vagrant-aws/tree/spot-3

@michaelbarton
Copy link

This would be useful for me too.

@mizzy
Copy link

mizzy commented Oct 20, 2014

👍

@tknerr
Copy link
Contributor

tknerr commented Oct 28, 2014

oh yes please 👍

@randywallace
Copy link

+1

@cadams500
Copy link

👍 Would be an awesome feature. In the meantime, I'm going to check out @nabeken's implementation.

@KostyaSha
Copy link

👍 any ETA for release?

@mrdavidlaing
Copy link

👍 for merging this

@shvenkat
Copy link

shvenkat commented Apr 8, 2015

Rebased onto current master at https://github.com/KariusDx/vagrant-aws/tree/spot

@dgreene3p
Copy link

If I could vote more than +1 this I would

@kalehrishi
Copy link

any ETA when this will be in master?

@sebastiang
Copy link

+1

4 similar comments
@haoyuan
Copy link

haoyuan commented Aug 4, 2015

+1

@ghost
Copy link

ghost commented Aug 5, 2015

+1

@yuzhu
Copy link

yuzhu commented Aug 11, 2015

+1

@fganglberger
Copy link

+1

@davidski
Copy link

davidski commented Sep 6, 2015

There have been outstanding PRs for this feature for over a year. @mitchellh - What can the user community do to help get this accepted and released in the main branch?

@kalehrishi
Copy link

@mitchellh It would be nice to have this feature.

@ermaker
Copy link

ermaker commented Dec 4, 2015

@mitchellh Any plans?

@3vcloud
Copy link

3vcloud commented Dec 9, 2015

There were issues with EBS settings not being passed through, and tagging wasn't working either. The tagging is more of a fog limitation, but I've added code to tag the server after its up to solve that one.

Created a pull request for https://github.com/KariusDx/vagrant-aws/tree/spot aswell

@VVMichaelSawyer
Copy link

+1

2 similar comments
@poflynn
Copy link

poflynn commented May 3, 2016

+1

@StevenVanAcker
Copy link

+1

@mh720
Copy link

mh720 commented May 8, 2016

@rtyler could you assist with this PR?

@mblanche
Copy link

Is there any development on this request? Pulled the spot_instances branch just to find that it was a stalled branch with broken features. Spot request would be a great addition to the aws plugin

@jhedev
Copy link

jhedev commented Oct 31, 2016

@mblanche Not sure if this helps you: I made a fork with some fixes to get it working. See here: https://github.com/jhedev/vagrant-aws/tree/spot (branch spot). I'm using it already and it works great. So maybe this is useful until the fixes are merged upstream...

@javnav
Copy link

javnav commented Jan 10, 2017

Hi @jhedev I just forked your repo and I'm trying to install the plugin with spot support. Unfortunately, I got this error: Unable to resolve dependency: user requested 'vagrant-aws (= 0.7.2.spot)'.
Sorry guys, but I don't understand what I'm doing wrong. These are my steps:

$ git checkout spot
$ gem build vagrant-aws.gemspec
$ vagrant plugin install vagrant-aws-0.7.2.spot.gem
Unable to resolve dependency: user requested 'vagrant-aws (= 0.7.2.spot)'

Can you help me, please?

@jhedev
Copy link

jhedev commented Jan 10, 2017

Hmm... I just tried your commands on a fresh copy of the repo and it works fine for me... I have to admit I'm not an ruby expert so not sure what's going on.

Was the gem build successful, i.e. is there a vagrant-aws-0.7.2.spot.gem file?

Maybe you can try uninstall any previously installed version of the vagrant-aws plugin.

@javnav
Copy link

javnav commented Jan 12, 2017

Hi @jhedev Thanks very much for your help! Should be something wrong in my configuration, if you can install the plugin following these steps... I had already uninstalled the previous one before installing this new version, but it looks like vagrant is trying to reinstall the remote version. I thing it needs some work to find out what's going on. Thanks!

@vavdoshka
Copy link

Hi @mitchellh Any chance to have it supported?

@mkubenka mkubenka linked a pull request Jun 18, 2017 that will close this issue
@mkubenka
Copy link

I have created new Gem vagrant-aws-mkubenka with spot instances support (#514).

Installation instructions:

vagrant plugin uninstall vagrant-aws
vagrant plugin install vagrant-aws-mkubenka --plugin-version "0.7.2.pre.14"

@harmanbirdi
Copy link

@mkubenka - Is there any reason 'vagrant reload' is disallowed from your plugin? I tried to do so to reboot the host, but I get the following error.

/.vagrant.d/gems/2.2.5/gems/excon-0.58.0/lib/excon/middlewares/expects.rb:7:in `response_call': UnsupportedOperation => The instance 'i-014c10ea90810dacc' is a spot instance and may not be stopped. (Fog::Compute::AWS::Error)

However, looking at AWS documentation on the same at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/how-spot-instances-work.html
it says the following:

Note that you can't stop and start an Amazon EBS-backed instance if it is a Spot instance, but you can reboot or terminate it.

I have the need to be able to reboot an AWS spot instance. Could you please let me know how I can achieve this?

@3vcloud
Copy link

3vcloud commented Sep 1, 2017

@harmanbirdi - One of the caveats to choosing to use spot instances is the fact that you can't stop the server - it has 2 states, running or destroyed. I'm not sure if the API allows a proper reboot, but traditionally Vagrant uses a combination of stop and start. You could try vagrant ssh to gain access and then shutdown -r now on linux to restart the server manually, but I'm not sure that would work either.

As a rule of thumb, try to only host code on a Spot Instance that can be wiped at any time without losing your data. (This should be the case with all types of cloud instance really, but we all know that its never as black and white as that in the real world!)

Don't forget that another caveat to a spot instance is that if the cost of your instance spikes above what you've said that you're prepared to pay, Amazon will reclaim your instance, destroying it in the process anyway.

@harmanbirdi
Copy link

harmanbirdi commented Sep 1, 2017

@3vcloud - I should have mentioned that I was able to successfully reboot spot instance from AWS UI. I did not try to do so via an API yet though. What I am looking for is the capability for vagrant reload to be able to reboot the spot instance because according to AWS documentation, it is possible to do so. I am aware of the limitations of spot instances, but still need to be able to reboot it via vagrant using reload.

I think there are three states - running (up), terminated (destroy), reboot (reload). I have put vagrant equivalents in parenthesis.

UPDATE - I was able to just successfully reboot the spot instance using command line as well.
You can see that the lifecycle is "spot" in the attached screenshot.

$ vagrant ssh ws-1
ubuntu@ip-10-128-168-173:~$ date
Fri Sep  1 07:13:25 UTC 2017
ubuntu@ip-10-128-168-173:~$ uptime
 07:13:31 up 2 min,  1 user,  load average: 1.35, 0.58, 0.22
ubuntu@ip-10-128-168-173:~$ sudo shutdown -r now

Broadcast message from ubuntu@ip-10-128-168-173
	(/dev/pts/0) at 7:15 ...

The system is going down for reboot NOW!
ubuntu@ip-10-128-168-173:~$ Connection to ec2-54-176-132-208.us-west-1.compute.amazonaws.com closed by remote host.
Connection to ec2-54-176-132-208.us-west-1.compute.amazonaws.com closed.
$ vagrant ssh ws-1
ubuntu@ip-10-128-168-173:~$ uptime
 07:16:54 up 1 min,  1 user,  load average: 1.55, 0.49, 0.17
ubuntu@ip-10-128-168-173:~$ 

image

@kadrach
Copy link

kadrach commented Oct 23, 2017

@3vcloud @harmanbirdi Spot instances can now be stopped, if EBS backed (which most are, nowadays). This feature was released publicly just last month, see here.

@3vcloud
Copy link

3vcloud commented Oct 23, 2017

@kadrach thanks for the clarification, I've been on the road since last year and didn't read up on the change

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.