-
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
Merged
Merged
[Subnet Prioritization] Support capacity-optimized-prioritized and prioritized Allocation Strategy #671
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
430c9a3
[Subnet Prioritization] Add SingleAvailabilityZone parameter to ec2 f…
Allenz5 2d21a5a
[Subnet Prioritization] Add Priority parameter to ec2 fleet call
Allenz5 7f70084
[Subnet Prioritization] Extend test_evaluate_launch_params to test pa…
Allenz5 01d3219
[Subnet Prioritization] Update CHANGELOG.md
Allenz5 c905f70
Merge branch 'aws:develop' into develop
Allenz5 4f2a6cb
[Subnet Prioritization] Check AllocationStrategy is prioritized|capac…
Allenz5 ddd8e41
Merge branch 'develop' of github.com:Allenz5/aws-parallelcluster-node…
Allenz5 56309ea
[Subnet Prioritization] Update CHANGELOG.md
Allenz5 cf11486
[Subnet Prioritization] Reformat the code to make it more clear
Allenz5 b028b40
[Subnet Prioritization] Reformat the code to make it more clear
Allenz5 a0a4775
[Subnet Prioritization] Add a valid condition to check that 'prioriti…
Allenz5 1efee32
[Subnet Prioritization] Remove EnableSingleAvailabilityZone parameter
Allenz5 e57dab8
[Subnet Prioritization] Update unit tests to test that priority is co…
Allenz5 f3cfc65
[Subnet Prioritization] Update unit tests to test that priority is co…
Allenz5 552dd0a
Merge branch 'develop' into develop
himani2411 7bbae42
[Subnet Prioritization] Update CHANGELOG.md
Allenz5 ef6f189
Merge remote-tracking branch 'origin/develop' into develop
Allenz5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,11 +296,21 @@ 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"] | ||
| for subnet_id in subnet_ids: | ||
| overrides.update({"InstanceType": instance_type["InstanceType"], "SubnetId": subnet_id}) | ||
| if ( | ||
| self._compute_resource_config.get("AllocationStrategy") == "prioritized" | ||
Allenz5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| or self._compute_resource_config.get("AllocationStrategy") == "capacity-optimized-prioritized" | ||
| ): | ||
| 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): | ||
|
|
@@ -317,8 +327,11 @@ def _evaluate_launch_params(self, count): | |
| try: | ||
| common_launch_options = { | ||
| "SingleInstanceType": self._uses_single_instance_type(), | ||
| "SingleAvailabilityZone": self._uses_single_az(), # If using Multi-AZ (by specifying multiple subnets), | ||
| # set SingleAvailabilityZone to False | ||
| "SingleAvailabilityZone": ( | ||
| self._compute_resource_config["Networking"]["SingleAvailabilityZone"] | ||
| if self._compute_resource_config["Networking"]["SingleAvailabilityZone"] is not None | ||
Allenz5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Allenz5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else self._uses_single_az() | ||
| ), | ||
| } | ||
| allocation_strategy = self._compute_resource_config.get("AllocationStrategy") | ||
| if allocation_strategy: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...er/test_evaluate_launch_params/capacity_optimized_prioritized/expected_launch_params.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "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 | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "OnDemandOptions": { | ||
| "AllocationStrategy": "capacity-optimized-prioritized", | ||
| "SingleInstanceType": false, | ||
| "SingleAvailabilityZone": true, | ||
| "CapacityReservationOptions": { | ||
| "UsageStrategy": "use-capacity-reservations-first" | ||
| } | ||
| }, | ||
| "TargetCapacitySpecification": { | ||
| "TotalTargetCapacity": 5, | ||
| "DefaultTargetCapacityType": "on-demand" | ||
| }, | ||
| "Type": "instant" | ||
| } |
45 changes: 45 additions & 0 deletions
45
...Ec2CreateFleetManager/test_evaluate_launch_params/prioritized/expected_launch_params.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": true, | ||
| "CapacityReservationOptions": { | ||
| "UsageStrategy": "use-capacity-reservations-first" | ||
| } | ||
| }, | ||
| "TargetCapacitySpecification": { | ||
| "TotalTargetCapacity": 5, | ||
| "DefaultTargetCapacityType": "on-demand" | ||
| }, | ||
| "Type": "instant" | ||
| } |
41 changes: 41 additions & 0 deletions
41
...stEc2CreateFleetManager/test_evaluate_launch_params/single_az/expected_launch_params.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "LaunchTemplateConfigs": [ | ||
| { | ||
| "LaunchTemplateSpecification": { | ||
| "LaunchTemplateName": "hit-queue-single-az-fleet1", | ||
| "Version": "$Latest" | ||
| }, | ||
| "Overrides": [ | ||
| { | ||
| "InstanceType": "t2.medium", | ||
| "SubnetId": "1234567" | ||
| }, | ||
| { | ||
| "InstanceType": "t2.medium", | ||
| "SubnetId": "7654321" | ||
| }, | ||
| { | ||
| "InstanceType": "t2.large", | ||
| "SubnetId": "1234567" | ||
| }, | ||
| { | ||
| "InstanceType": "t2.large", | ||
| "SubnetId": "7654321" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "OnDemandOptions": { | ||
| "AllocationStrategy": "lowest-price", | ||
| "SingleInstanceType": false, | ||
| "SingleAvailabilityZone": true, | ||
| "CapacityReservationOptions": { | ||
| "UsageStrategy": "use-capacity-reservations-first" | ||
| } | ||
| }, | ||
| "TargetCapacitySpecification": { | ||
| "TotalTargetCapacity": 5, | ||
| "DefaultTargetCapacityType": "on-demand" | ||
| }, | ||
| "Type": "instant" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.