Skip to content

Conversation

Allenz5
Copy link
Contributor

@Allenz5 Allenz5 commented Jun 17, 2025

Description of changes

  • Add Priority to subnets when creating fleet using capacity-optimized-prioritized and prioritized Allocation Strategy

Tests

  • Extended test_fleet_manager.py::test_fleet_manager.py to test that Priority is appended in overrides when using capacity-optimized-prioritized and prioritized Allocation Strategy

References

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Allenz5 and others added 5 commits June 11, 2025 11:03
…rams launching with EnableSingleAvailabilityZone and prioritized|capacity-optimized-prioritized AllocationStrategy

Signed-off-by: Hanxuan Zhang <[email protected]>
@Allenz5 Allenz5 requested review from a team as code owners June 17, 2025 17:09
Allenz5 added 2 commits June 18, 2025 15:59
…ity-optimized-prioritized when using EnableSingleAvailabilityZone

Signed-off-by: Hanxuan Zhang <[email protected]>
…zed' is used with On-Demand Capacity and 'capacity-optimized-prioritized' is used with Spot Capacity type.

Signed-off-by: Hanxuan Zhang <[email protected]>
@himani2411
Copy link
Contributor

Update the PR description to mention what is no longer relevant

Allenz5 added 2 commits July 9, 2025 13:08
…rrectly set with prioritized|capacity-optimized-prioritized AllocationStrategy and all_or_nothing ScalingStrategy

Signed-off-by: Hanxuan Zhang <[email protected]>
…rrectly set with prioritized|capacity-optimized-prioritized AllocationStrategy and all_or_nothing ScalingStrategy

Signed-off-by: Hanxuan Zhang <[email protected]>
himani2411
himani2411 previously approved these changes Jul 9, 2025
@himani2411 himani2411 merged commit d3db0f4 into aws:develop Jul 9, 2025
9 checks passed
for subnet_id in subnet_ids:
overrides.update({"InstanceType": instance_type["InstanceType"], "SubnetId": subnet_id})
if self._uses_subnet_prioritization():
overrides.update(
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

------

**CHANGES**
- Support prioritized and capacity-optimized-prioritized Allocation Strategy
Copy link
Contributor

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 and capacity-optimized-prioritized to take into account the subnet prioritization on scale out."


def _uses_subnet_prioritization(self):
return (
self._compute_resource_config.get("AllocationStrategy") == "prioritized"
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

subnet_ids = self._compute_resource_config.get("Networking", {}).get("SubnetIds", [])
return len(subnet_ids) == 1

def _uses_subnet_prioritization(self):
Copy link
Contributor

Choose a reason for hiding this comment

The 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 _evaluate_template_overrides. However, we should always add a specific unit test for every new function and mock its behavior in unit tests for the upper level one. In this way it's easier to decouple behavior and address defects in case of failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants