{"action":"created","comment":{"url":"https://api.github.com/repos/nchammas/flintrock/pulls/comments/43118088","id":43118088,"diff_hunk":"@@ -533,31 +528,82 @@ def launch_ec2(\n         vpc_id=vpc_id,\n         region=region)\n \n+    num_instances = num_slaves + 1\n     try:\n         connection = boto.ec2.connect_to_region(region_name=region)\n \n-        print(\"Launching {c} instances...\".format(c=num_slaves + 1))\n-\n-        reservation = connection.run_instances(\n-            image_id=ami,\n-            min_count=(num_slaves + 1),\n-            max_count=(num_slaves + 1),\n-            key_name=key_name,\n-            instance_type=instance_type,\n-            placement=availability_zone,\n-            security_group_ids=[sg.id for sg in security_groups],\n-            subnet_id=subnet_id,\n-            placement_group=placement_group,\n-            tenancy=tenancy,\n-            ebs_optimized=ebs_optimized,\n-            instance_initiated_shutdown_behavior=instance_initiated_shutdown_behavior)\n-\n-        time.sleep(10)  # AWS metadata eventual consistency tax.\n+        if spot_price is not None:\n+            print(\"Requesting {c} spot instances at a max price of {p}\".format(c=num_instances, p=spot_price))\n+\n+            instance_reqs = connection.request_spot_instances(\n+                price=spot_price,\n+                image_id=ami,\n+                count=(num_instances),\n+                key_name=key_name,\n+                instance_type=instance_type,\n+                placement=availability_zone,\n+                security_group_ids=[sg.id for sg in security_groups],\n+                subnet_id=subnet_id,\n+                placement_group=placement_group,\n+                ebs_optimized=ebs_optimized)\n+\n+            spot_instance_request_ids = [sir.id for sir in instance_reqs]\n+\n+            try:\n+                while True:\n+                    time.sleep(30)","path":"flintrock.py","position":56,"original_position":56,"commit_id":"da70bb3a911e7f9025235af141ecf710fa4e2eca","original_commit_id":"da70bb3a911e7f9025235af141ecf710fa4e2eca","user":{"login":"ericmjonas","id":36626,"avatar_url":"https://avatars.githubusercontent.com/u/36626?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmjonas","html_url":"https://github.com/ericmjonas","followers_url":"https://api.github.com/users/ericmjonas/followers","following_url":"https://api.github.com/users/ericmjonas/following{/other_user}","gists_url":"https://api.github.com/users/ericmjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmjonas/subscriptions","organizations_url":"https://api.github.com/users/ericmjonas/orgs","repos_url":"https://api.github.com/users/ericmjonas/repos","events_url":"https://api.github.com/users/ericmjonas/events{/privacy}","received_events_url":"https://api.github.com/users/ericmjonas/received_events","type":"User","site_admin":false},"body":"I think so -- even small spot instance requests (say for 5 instances) can take ~90 seconds to be approved (by whatever method Amazon uses to make sure you're not going to break everything) and then 2-3 min to grant, depending on price. ","created_at":"2015-10-27T13:08:42Z","updated_at":"2015-10-27T13:08:42Z","html_url":"https://github.com/nchammas/flintrock/pull/35#discussion_r43118088","pull_request_url":"https://api.github.com/repos/nchammas/flintrock/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/comments/43118088"},"html":{"href":"https://github.com/nchammas/flintrock/pull/35#discussion_r43118088"},"pull_request":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/nchammas/flintrock/pulls/35","id":48689207,"html_url":"https://github.com/nchammas/flintrock/pull/35","diff_url":"https://github.com/nchammas/flintrock/pull/35.diff","patch_url":"https://github.com/nchammas/flintrock/pull/35.patch","issue_url":"https://api.github.com/repos/nchammas/flintrock/issues/35","number":35,"state":"open","locked":false,"title":"Initial spot instance support","user":{"login":"ericmjonas","id":36626,"avatar_url":"https://avatars.githubusercontent.com/u/36626?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmjonas","html_url":"https://github.com/ericmjonas","followers_url":"https://api.github.com/users/ericmjonas/followers","following_url":"https://api.github.com/users/ericmjonas/following{/other_user}","gists_url":"https://api.github.com/users/ericmjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmjonas/subscriptions","organizations_url":"https://api.github.com/users/ericmjonas/orgs","repos_url":"https://api.github.com/users/ericmjonas/repos","events_url":"https://api.github.com/users/ericmjonas/events{/privacy}","received_events_url":"https://api.github.com/users/ericmjonas/received_events","type":"User","site_admin":false},"body":"This isn't a final pull request but more a point to begin discussion. It works successfully in `us-west-2` and `us-east-1`. \r\n\r\nWhen you make a spot instance request for N machines, this might result in up to N \"reservations\" for some number of machines (such that the total is the size of your spot request). Hence having to aggregate the results a bit - both types now contribute to an `all_instances` variable. \r\n\r\n@nchammas is this what you were thinking? Any feedback? \r\n","created_at":"2015-10-25T22:04:35Z","updated_at":"2015-10-27T13:08:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2320eb23ddba7e048bf0e9300c073ffa0f59d8aa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nchammas/flintrock/pulls/35/commits","review_comments_url":"https://api.github.com/repos/nchammas/flintrock/pulls/35/comments","review_comment_url":"https://api.github.com/repos/nchammas/flintrock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nchammas/flintrock/issues/35/comments","statuses_url":"https://api.github.com/repos/nchammas/flintrock/statuses/da70bb3a911e7f9025235af141ecf710fa4e2eca","head":{"label":"ericmjonas:add-spot-instance-support","ref":"add-spot-instance-support","sha":"da70bb3a911e7f9025235af141ecf710fa4e2eca","user":{"login":"ericmjonas","id":36626,"avatar_url":"https://avatars.githubusercontent.com/u/36626?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmjonas","html_url":"https://github.com/ericmjonas","followers_url":"https://api.github.com/users/ericmjonas/followers","following_url":"https://api.github.com/users/ericmjonas/following{/other_user}","gists_url":"https://api.github.com/users/ericmjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmjonas/subscriptions","organizations_url":"https://api.github.com/users/ericmjonas/orgs","repos_url":"https://api.github.com/users/ericmjonas/repos","events_url":"https://api.github.com/users/ericmjonas/events{/privacy}","received_events_url":"https://api.github.com/users/ericmjonas/received_events","type":"User","site_admin":false},"repo":{"id":44893968,"name":"flintrock","full_name":"ericmjonas/flintrock","owner":{"login":"ericmjonas","id":36626,"avatar_url":"https://avatars.githubusercontent.com/u/36626?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmjonas","html_url":"https://github.com/ericmjonas","followers_url":"https://api.github.com/users/ericmjonas/followers","following_url":"https://api.github.com/users/ericmjonas/following{/other_user}","gists_url":"https://api.github.com/users/ericmjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmjonas/subscriptions","organizations_url":"https://api.github.com/users/ericmjonas/orgs","repos_url":"https://api.github.com/users/ericmjonas/repos","events_url":"https://api.github.com/users/ericmjonas/events{/privacy}","received_events_url":"https://api.github.com/users/ericmjonas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericmjonas/flintrock","description":"A command-line tool and library for launching Apache Spark clusters.","fork":true,"url":"https://api.github.com/repos/ericmjonas/flintrock","forks_url":"https://api.github.com/repos/ericmjonas/flintrock/forks","keys_url":"https://api.github.com/repos/ericmjonas/flintrock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericmjonas/flintrock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericmjonas/flintrock/teams","hooks_url":"https://api.github.com/repos/ericmjonas/flintrock/hooks","issue_events_url":"https://api.github.com/repos/ericmjonas/flintrock/issues/events{/number}","events_url":"https://api.github.com/repos/ericmjonas/flintrock/events","assignees_url":"https://api.github.com/repos/ericmjonas/flintrock/assignees{/user}","branches_url":"https://api.github.com/repos/ericmjonas/flintrock/branches{/branch}","tags_url":"https://api.github.com/repos/ericmjonas/flintrock/tags","blobs_url":"https://api.github.com/repos/ericmjonas/flintrock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericmjonas/flintrock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericmjonas/flintrock/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericmjonas/flintrock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericmjonas/flintrock/statuses/{sha}","languages_url":"https://api.github.com/repos/ericmjonas/flintrock/languages","stargazers_url":"https://api.github.com/repos/ericmjonas/flintrock/stargazers","contributors_url":"https://api.github.com/repos/ericmjonas/flintrock/contributors","subscribers_url":"https://api.github.com/repos/ericmjonas/flintrock/subscribers","subscription_url":"https://api.github.com/repos/ericmjonas/flintrock/subscription","commits_url":"https://api.github.com/repos/ericmjonas/flintrock/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericmjonas/flintrock/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericmjonas/flintrock/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericmjonas/flintrock/issues/comments{/number}","contents_url":"https://api.github.com/repos/ericmjonas/flintrock/contents/{+path}","compare_url":"https://api.github.com/repos/ericmjonas/flintrock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericmjonas/flintrock/merges","archive_url":"https://api.github.com/repos/ericmjonas/flintrock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericmjonas/flintrock/downloads","issues_url":"https://api.github.com/repos/ericmjonas/flintrock/issues{/number}","pulls_url":"https://api.github.com/repos/ericmjonas/flintrock/pulls{/number}","milestones_url":"https://api.github.com/repos/ericmjonas/flintrock/milestones{/number}","notifications_url":"https://api.github.com/repos/ericmjonas/flintrock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericmjonas/flintrock/labels{/name}","releases_url":"https://api.github.com/repos/ericmjonas/flintrock/releases{/id}","created_at":"2015-10-25T02:52:53Z","updated_at":"2015-10-25T02:52:54Z","pushed_at":"2015-10-26T03:41:54Z","git_url":"git://github.com/ericmjonas/flintrock.git","ssh_url":"git@github.com:ericmjonas/flintrock.git","clone_url":"https://github.com/ericmjonas/flintrock.git","svn_url":"https://github.com/ericmjonas/flintrock","homepage":null,"size":451,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nchammas:master","ref":"master","sha":"a1a5a7e8216b61eeaf8f33512c3da2b5142c542d","user":{"login":"nchammas","id":1039369,"avatar_url":"https://avatars.githubusercontent.com/u/1039369?v=3","gravatar_id":"","url":"https://api.github.com/users/nchammas","html_url":"https://github.com/nchammas","followers_url":"https://api.github.com/users/nchammas/followers","following_url":"https://api.github.com/users/nchammas/following{/other_user}","gists_url":"https://api.github.com/users/nchammas/gists{/gist_id}","starred_url":"https://api.github.com/users/nchammas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nchammas/subscriptions","organizations_url":"https://api.github.com/users/nchammas/orgs","repos_url":"https://api.github.com/users/nchammas/repos","events_url":"https://api.github.com/users/nchammas/events{/privacy}","received_events_url":"https://api.github.com/users/nchammas/received_events","type":"User","site_admin":false},"repo":{"id":36854444,"name":"flintrock","full_name":"nchammas/flintrock","owner":{"login":"nchammas","id":1039369,"avatar_url":"https://avatars.githubusercontent.com/u/1039369?v=3","gravatar_id":"","url":"https://api.github.com/users/nchammas","html_url":"https://github.com/nchammas","followers_url":"https://api.github.com/users/nchammas/followers","following_url":"https://api.github.com/users/nchammas/following{/other_user}","gists_url":"https://api.github.com/users/nchammas/gists{/gist_id}","starred_url":"https://api.github.com/users/nchammas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nchammas/subscriptions","organizations_url":"https://api.github.com/users/nchammas/orgs","repos_url":"https://api.github.com/users/nchammas/repos","events_url":"https://api.github.com/users/nchammas/events{/privacy}","received_events_url":"https://api.github.com/users/nchammas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nchammas/flintrock","description":"A command-line tool and library for launching Apache Spark clusters.","fork":false,"url":"https://api.github.com/repos/nchammas/flintrock","forks_url":"https://api.github.com/repos/nchammas/flintrock/forks","keys_url":"https://api.github.com/repos/nchammas/flintrock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nchammas/flintrock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nchammas/flintrock/teams","hooks_url":"https://api.github.com/repos/nchammas/flintrock/hooks","issue_events_url":"https://api.github.com/repos/nchammas/flintrock/issues/events{/number}","events_url":"https://api.github.com/repos/nchammas/flintrock/events","assignees_url":"https://api.github.com/repos/nchammas/flintrock/assignees{/user}","branches_url":"https://api.github.com/repos/nchammas/flintrock/branches{/branch}","tags_url":"https://api.github.com/repos/nchammas/flintrock/tags","blobs_url":"https://api.github.com/repos/nchammas/flintrock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nchammas/flintrock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nchammas/flintrock/git/refs{/sha}","trees_url":"https://api.github.com/repos/nchammas/flintrock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nchammas/flintrock/statuses/{sha}","languages_url":"https://api.github.com/repos/nchammas/flintrock/languages","stargazers_url":"https://api.github.com/repos/nchammas/flintrock/stargazers","contributors_url":"https://api.github.com/repos/nchammas/flintrock/contributors","subscribers_url":"https://api.github.com/repos/nchammas/flintrock/subscribers","subscription_url":"https://api.github.com/repos/nchammas/flintrock/subscription","commits_url":"https://api.github.com/repos/nchammas/flintrock/commits{/sha}","git_commits_url":"https://api.github.com/repos/nchammas/flintrock/git/commits{/sha}","comments_url":"https://api.github.com/repos/nchammas/flintrock/comments{/number}","issue_comment_url":"https://api.github.com/repos/nchammas/flintrock/issues/comments{/number}","contents_url":"https://api.github.com/repos/nchammas/flintrock/contents/{+path}","compare_url":"https://api.github.com/repos/nchammas/flintrock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nchammas/flintrock/merges","archive_url":"https://api.github.com/repos/nchammas/flintrock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nchammas/flintrock/downloads","issues_url":"https://api.github.com/repos/nchammas/flintrock/issues{/number}","pulls_url":"https://api.github.com/repos/nchammas/flintrock/pulls{/number}","milestones_url":"https://api.github.com/repos/nchammas/flintrock/milestones{/number}","notifications_url":"https://api.github.com/repos/nchammas/flintrock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nchammas/flintrock/labels{/name}","releases_url":"https://api.github.com/repos/nchammas/flintrock/releases{/id}","created_at":"2015-06-04T07:14:30Z","updated_at":"2015-10-25T20:57:51Z","pushed_at":"2015-10-26T03:41:54Z","git_url":"git://github.com/nchammas/flintrock.git","ssh_url":"git@github.com:nchammas/flintrock.git","clone_url":"https://github.com/nchammas/flintrock.git","svn_url":"https://github.com/nchammas/flintrock","homepage":null,"size":451,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":18,"forks":3,"open_issues":18,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/35"},"html":{"href":"https://github.com/nchammas/flintrock/pull/35"},"issue":{"href":"https://api.github.com/repos/nchammas/flintrock/issues/35"},"comments":{"href":"https://api.github.com/repos/nchammas/flintrock/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nchammas/flintrock/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/nchammas/flintrock/statuses/da70bb3a911e7f9025235af141ecf710fa4e2eca"}}}}