-
Notifications
You must be signed in to change notification settings - Fork 403
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
ec2_asg: add support for Spot allocation #418
Changes from all commits
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -93,6 +93,14 @@ | |||||||||
- A list of instance_types. | ||||||||||
type: list | ||||||||||
elements: str | ||||||||||
ondemand_base: | ||||||||||
description: | ||||||||||
- the minimum amount of capacity that must be fulfilled by On-Demand instances | ||||||||||
type: int | ||||||||||
ondemand_percentage_above_base: | ||||||||||
description: | ||||||||||
- percentages of on-demand instances beyond OnDemandBaseCapacity | ||||||||||
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.
Suggested change
|
||||||||||
type: int | ||||||||||
type: dict | ||||||||||
placement_group: | ||||||||||
description: | ||||||||||
|
@@ -743,6 +751,10 @@ def get_properties(autoscaling_group): | |||||||||
raw_mixed_instance_object = autoscaling_group.get('MixedInstancesPolicy') | ||||||||||
if raw_mixed_instance_object: | ||||||||||
properties['mixed_instances_policy'] = [x['InstanceType'] for x in raw_mixed_instance_object.get('LaunchTemplate').get('Overrides')] | ||||||||||
if 'OnDemandPercentageAboveBaseCapacity' in raw_mixed_instance_object.get('InstancesDistribution', []): | ||||||||||
properties['ondemand_percentage_above_base'] = raw_mixed_instance_object.get('InstancesDistribution').get('OnDemandPercentageAboveBaseCapacity') | ||||||||||
if 'OnDemandBaseCapacity' in raw_mixed_instance_object.get('InstancesDistribution', []): | ||||||||||
properties['ondemand_base'] = raw_mixed_instance_object.get('InstancesDistribution').get('OnDemandBaseCapacity') | ||||||||||
|
||||||||||
metrics = autoscaling_group.get('EnabledMetrics') | ||||||||||
if metrics: | ||||||||||
|
@@ -802,6 +814,10 @@ def get_launch_object(connection, ec2_connection): | |||||||||
for instance_type in instance_types: | ||||||||||
instance_type_dict = {'InstanceType': instance_type} | ||||||||||
policy['LaunchTemplate']['Overrides'].append(instance_type_dict) | ||||||||||
policy['InstancesDistribution'] = { | ||||||||||
'OnDemandPercentageAboveBaseCapacity': mixed_instances_policy.get('ondemand_percentage_above_base'), | ||||||||||
'OnDemandBaseCapacity': mixed_instances_policy.get('ondemand_base') | ||||||||||
} | ||||||||||
launch_object['MixedInstancesPolicy'] = policy | ||||||||||
return launch_object | ||||||||||
|
||||||||||
|
@@ -1661,6 +1677,8 @@ def main(): | |||||||||
type='list', | ||||||||||
elements='str' | ||||||||||
), | ||||||||||
ondemand_percentage_above_base=dict(type='int'), | ||||||||||
ondemand_base=dict(type='int') | ||||||||||
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.
Suggested change
By leaving the comma at the end it simplifies patches for future features (they don't need to change this line, they just add the next one). Which then helps if you ever need to use |
||||||||||
) | ||||||||||
), | ||||||||||
placement_group=dict(type='str'), | ||||||||||
|
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.