You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/12/28 06:17:10 UTC
[GitHub] [libcloud] yukw777 opened a new pull request #1398: Support for aws
ec2 spot instances
yukw777 opened a new pull request #1398: Support for aws ec2 spot instances
URL: https://github.com/apache/libcloud/pull/1398
## Support for aws ec2 spot instances
### Description
Support for aws ec2 spot instances. The previous PR (https://github.com/apache/libcloud/pull/1207) went stale, so I decided to create a new one. I've added a unit test and ran a manual test with the following script:
```python
import os
import time
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
from libcloud.compute.base import NodeImage
from libcloud.compute.types import NodeState
SIZE_ID = 't1.micro'
AMI_ID = 'ami-04b9e92b5572fa0d1'
REGION = 'us-east-1'
KEYPAIR_NAME = 'key'
SECURITY_GROUP_NAMES = ['default']
NODE_NAME = 'test-spot-node'
def create_spot_request(accessid, secretkey):
cls = get_driver(Provider.EC2)
driver = cls(accessid, secretkey, region=REGION)
sizes = driver.list_sizes()
size = [s for s in sizes if s.id == SIZE_ID][0]
image = NodeImage(id=AMI_ID, name=None, driver=driver)
# create the spot instance
node = driver.create_node(
name=NODE_NAME,
size=size,
image=image,
ex_spot=True,
ex_spot_max_price=0.005,
ex_keyname=KEYPAIR_NAME,
ex_security_groups=SECURITY_GROUP_NAMES)
print("Spot instance created: '%s" % node.id)
assert node.extra.get('instance_lifecycle') == 'spot'
print("Destroying node...")
driver.destroy_node(node)
while node.state != NodeState.TERMINATED:
print("...waiting to be terminated (State: %s)" % node.state)
node = driver.list_nodes(ex_node_ids=[node.id])[0]
time.sleep(5)
def main():
accessid = os.getenv('ACCESSID')
secretkey = os.getenv('SECRETKEY')
if accessid and secretkey:
create_spot_request(accessid, secretkey)
else:
print('ACCESSID and SECRETKEY are sourced from the environment')
if __name__ == "__main__":
main()
```
### Status
done, ready for review
### Checklist (tick everything that applies)
- [x] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks)
- [x] Documentation
- [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [x] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [libcloud] codecov-io commented on issue #1398: Support for aws ec2
spot instances
Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #1398: Support for aws ec2 spot instances
URL: https://github.com/apache/libcloud/pull/1398#issuecomment-569390509
# [Codecov](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=h1) Report
> Merging [#1398](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=desc) into [trunk](https://codecov.io/gh/apache/libcloud/commit/043bb6d46248384bb6bc4357aa47c0c201d16b7b?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/libcloud/pull/1398/graphs/tree.svg?width=650&token=PYoduksh69&height=150&src=pr)](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## trunk #1398 +/- ##
==========================================
+ Coverage 86.58% 86.58% +<.01%
==========================================
Files 364 364
Lines 76193 76208 +15
Branches 7439 7441 +2
==========================================
+ Hits 65968 65983 +15
Misses 7400 7400
Partials 2825 2825
```
| [Impacted Files](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [libcloud/compute/drivers/ec2.py](https://codecov.io/gh/apache/libcloud/pull/1398/diff?src=pr&el=tree#diff-bGliY2xvdWQvY29tcHV0ZS9kcml2ZXJzL2VjMi5weQ==) | `75.27% <100%> (+0.06%)` | :arrow_up: |
| [libcloud/test/compute/test\_ec2.py](https://codecov.io/gh/apache/libcloud/pull/1398/diff?src=pr&el=tree#diff-bGliY2xvdWQvdGVzdC9jb21wdXRlL3Rlc3RfZWMyLnB5) | `97.97% <100%> (+0.01%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=footer). Last update [043bb6d...b1b59d1](https://codecov.io/gh/apache/libcloud/pull/1398?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [libcloud] Kami commented on issue #1398: Support for aws ec2 spot
instances
Posted by GitBox <gi...@apache.org>.
Kami commented on issue #1398: Support for aws ec2 spot instances
URL: https://github.com/apache/libcloud/pull/1398#issuecomment-571899357
LGTM, thanks for the contribution :+1:
If you get a chance it would also be nice to add an example to documentation which shows how to create a spot instance.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [libcloud] Kami merged pull request #1398: Support for aws ec2 spot
instances
Posted by GitBox <gi...@apache.org>.
Kami merged pull request #1398: Support for aws ec2 spot instances
URL: https://github.com/apache/libcloud/pull/1398
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services