-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Support multiple availability zones in AWS (fix #2177) #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
84f9483
324035b
67a6dfa
a6cf834
7af3e14
ef24c88
b56d34d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
| import random | ||
|
|
||
| import boto3 | ||
| from botocore.config import Config | ||
|
|
||
|
|
@@ -35,6 +37,9 @@ def __init__(self, provider_config, cluster_name): | |
| self.ec2 = boto3.resource( | ||
| "ec2", region_name=provider_config["region"], config=config) | ||
|
|
||
| # Try availability zones round-robin, starting from random offset | ||
| self.subnet_idx = random.randint(0, 100) | ||
|
|
||
| # Cache of node objects from the last nodes() call. This avoids | ||
| # excessive DescribeInstances requests. | ||
| self.cached_nodes = {} | ||
|
|
@@ -121,9 +126,13 @@ def create_node(self, node_config, tags, count): | |
| "Key": k, | ||
| "Value": v, | ||
| }) | ||
| subnet_ids = conf.pop('SubnetIds') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: double quotes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment here that SubnetIds is not a real config key, and we need to resolve it before handing it to AWS
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, comment added |
||
| subnet_id = subnet_ids[self.subnet_idx % len(subnet_ids)] | ||
| self.subnet_idx += 1 | ||
| conf.update({ | ||
| "MinCount": 1, | ||
| "MaxCount": count, | ||
| "SubnetId": subnet_id, | ||
| "TagSpecifications": conf.get("TagSpecifications", []) + [{ | ||
| "ResourceType": "instance", | ||
| "Tags": tag_pairs, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to keep the map_public_ip_on_launch filter, at least for the head node? I know we don't require it for worker nodes any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is already performed on line 149; the later checks I believe are redundant so I removed them.