-
Notifications
You must be signed in to change notification settings - Fork 90
[Subnet Prioritization] Support capacity-optimized-prioritized and prioritized Allocation Strategy #671
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
[Subnet Prioritization] Support capacity-optimized-prioritized and prioritized Allocation Strategy #671
Changes from all commits
430c9a3
2d21a5a
7f70084
01d3219
c905f70
4f2a6cb
ddd8e41
56309ea
cf11486
b028b40
a0a4775
1efee32
e57dab8
f3cfc65
552dd0a
7bbae42
ef6f189
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 |
---|---|---|
|
@@ -296,11 +296,18 @@ def _evaluate_template_overrides(self) -> list: | |
if self._compute_resource_config.get("MaxPrice"): | ||
overrides.update({"MaxPrice": str(self._compute_resource_config["MaxPrice"])}) | ||
|
||
priority = 0.0 | ||
for instance_type in self._compute_resource_config["Instances"]: | ||
subnet_ids = self._compute_resource_config["Networking"]["SubnetIds"] | ||
subnet_ids = self._compute_resource_config.get("Networking", {}).get("SubnetIds", []) | ||
for subnet_id in subnet_ids: | ||
overrides.update({"InstanceType": instance_type["InstanceType"], "SubnetId": subnet_id}) | ||
if self._uses_subnet_prioritization(): | ||
overrides.update( | ||
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. [CodeStyle] We could reduce code duplication by defining the common part of the dictionary just once, then add the priority to it if subnet prioritization is enabled. |
||
{"InstanceType": instance_type["InstanceType"], "SubnetId": subnet_id, "Priority": priority} | ||
) | ||
else: | ||
overrides.update({"InstanceType": instance_type["InstanceType"], "SubnetId": subnet_id}) | ||
template_overrides.append(copy.deepcopy(overrides)) | ||
priority += 1.0 | ||
return template_overrides | ||
|
||
def _uses_single_instance_type(self): | ||
|
@@ -312,6 +319,15 @@ def _uses_single_az(self): | |
subnet_ids = self._compute_resource_config.get("Networking", {}).get("SubnetIds", []) | ||
return len(subnet_ids) == 1 | ||
|
||
def _uses_subnet_prioritization(self): | ||
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. [Tests] We are introducing a new function. We are testing it as part of the unit tests for the upper level function |
||
return ( | ||
self._compute_resource_config.get("AllocationStrategy") == "prioritized" | ||
Allenz5 marked this conversation as resolved.
Show resolved
Hide resolved
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. [CodeStyle] "prioritized", "on-demand", "spot", "capacity-optimized-prioritized" should be defined as constants in an Enum within a common script (see how we did it in cli package: https://github.com/aws/aws-parallelcluster/blob/develop/cli/src/pcluster/config/common.py#L31-L36). This is a good way to use the code as a way to document supported values, prevent constants to be redefined and potential errors caused by typos. |
||
and self._compute_resource_config["CapacityType"] == "on-demand" | ||
) or ( | ||
self._compute_resource_config.get("AllocationStrategy") == "capacity-optimized-prioritized" | ||
and self._compute_resource_config["CapacityType"] == "spot" | ||
) | ||
|
||
def _evaluate_launch_params(self, count): | ||
"""Evaluate parameters to be passed to create_fleet call.""" | ||
try: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"LaunchTemplateConfigs": [ | ||
{ | ||
"LaunchTemplateSpecification": { | ||
"LaunchTemplateName": "hit-queue-capacity-optimized-prioritized-fleet1", | ||
"Version": "$Latest" | ||
}, | ||
"Overrides": [ | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "1234567", | ||
"Priority": 0.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "7654321", | ||
"Priority": 1.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.large", | ||
"SubnetId": "1234567", | ||
"Priority": 2.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.large", | ||
"SubnetId": "7654321", | ||
"Priority": 3.0 | ||
} | ||
] | ||
} | ||
], | ||
"SpotOptions": { | ||
"SingleInstanceType": false, | ||
"SingleAvailabilityZone": false, | ||
"AllocationStrategy": "capacity-optimized-prioritized" | ||
}, | ||
"TargetCapacitySpecification": { | ||
"TotalTargetCapacity": 5, | ||
"DefaultTargetCapacityType": "spot" | ||
}, | ||
"Type": "instant" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"LaunchTemplateConfigs": [ | ||
{ | ||
"LaunchTemplateSpecification": { | ||
"LaunchTemplateName": "hit-queue-capacity-optimized-prioritized-all-or-nothing-fleet1", | ||
"Version": "$Latest" | ||
}, | ||
"Overrides": [ | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "1234567", | ||
"Priority": 0.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "7654321", | ||
"Priority": 1.0 | ||
} | ||
] | ||
} | ||
], | ||
"SpotOptions": { | ||
"SingleInstanceType": true, | ||
"SingleAvailabilityZone": false, | ||
"AllocationStrategy": "capacity-optimized-prioritized", | ||
"MinTargetCapacity": 5 | ||
}, | ||
"TargetCapacitySpecification": { | ||
"TotalTargetCapacity": 5, | ||
"DefaultTargetCapacityType": "spot" | ||
}, | ||
"Type": "instant" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"LaunchTemplateConfigs": [ | ||
{ | ||
"LaunchTemplateSpecification": { | ||
"LaunchTemplateName": "hit-queue-prioritized-fleet1", | ||
"Version": "$Latest" | ||
}, | ||
"Overrides": [ | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "1234567", | ||
"Priority": 0.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "7654321", | ||
"Priority": 1.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.large", | ||
"SubnetId": "1234567", | ||
"Priority": 2.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.large", | ||
"SubnetId": "7654321", | ||
"Priority": 3.0 | ||
} | ||
] | ||
} | ||
], | ||
"OnDemandOptions": { | ||
"AllocationStrategy": "prioritized", | ||
"SingleInstanceType": false, | ||
"SingleAvailabilityZone": false, | ||
Allenz5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"CapacityReservationOptions": { | ||
"UsageStrategy": "use-capacity-reservations-first" | ||
} | ||
}, | ||
"TargetCapacitySpecification": { | ||
"TotalTargetCapacity": 5, | ||
"DefaultTargetCapacityType": "on-demand" | ||
}, | ||
"Type": "instant" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"LaunchTemplateConfigs": [ | ||
{ | ||
"LaunchTemplateSpecification": { | ||
"LaunchTemplateName": "hit-queue-prioritized-all-or-nothing-fleet1", | ||
"Version": "$Latest" | ||
}, | ||
"Overrides": [ | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "1234567", | ||
"Priority": 0.0 | ||
}, | ||
{ | ||
"InstanceType": "t2.medium", | ||
"SubnetId": "7654321", | ||
"Priority": 1.0 | ||
} | ||
] | ||
} | ||
], | ||
"OnDemandOptions": { | ||
"AllocationStrategy": "prioritized", | ||
"SingleInstanceType": true, | ||
"SingleAvailabilityZone": false, | ||
"CapacityReservationOptions": { | ||
"UsageStrategy": "use-capacity-reservations-first" | ||
}, | ||
"MinTargetCapacity": 5 | ||
}, | ||
"TargetCapacitySpecification": { | ||
"TotalTargetCapacity": 5, | ||
"DefaultTargetCapacityType": "on-demand" | ||
}, | ||
"Type": "instant" | ||
} |
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.
The change log entry should be more focus on the user experience. Could even simply be "Support new allocation strategies
prioritized
andcapacity-optimized-prioritized
to take into account the subnet prioritization on scale out."