aws-batch: documentation gives wrong default for allocation strategy
Describe the issue
On https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.AllocationStrategy.html and other pages, the default allocation strategy is listed as SPOT_CAPACITY_OPTIMIZED if using Spot instances. However, the default was actually changed to SPOT_PRICE_CAPACITY_OPTIMIZED a couple of years ago in https://github.com/aws/aws-cdk/commit/e0ca252acee8290558edddde137458a055ad0b9e and some docs were not updated at that time
Links
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.AllocationStrategy.html
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EcsComputeEnvironment.html#allocationstrategy
Some code links, there may be more:
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L21
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L112
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L263
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L466
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L543
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L818
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L960
Hi @JackDunnNZ,
Thank you for reporting this documentation inconsistency. You're correct - the default allocation strategy was changed from SPOT_CAPACITY_OPTIMIZED to SPOT_PRICE_CAPACITY_OPTIMIZED in PR #26731 back in August 2023, but several JSDoc comments in the source code were not updated at that time.
The actual implementation in determineAllocationStrategy is correct and uses SPOT_PRICE_CAPACITY_OPTIMIZED as the default for Spot instances. The issue is purely in the documentation comments that generate the published API docs.
The fix involves updating the @default JSDoc comments at the locations you identified in managed-compute-environment.ts to reflect the correct default value. This is a good first contribution opportunity if you'd like to submit a PR! The changes would be:
- Update all
@defaultcomments that mention allocation strategy - Replace
SPOT_CAPACITY_OPTIMIZEDwithSPOT_PRICE_CAPACITY_OPTIMIZED - Ensure consistency across all interfaces (
IManagedEc2EcsComputeEnvironment,ManagedEc2EcsComputeEnvironmentProps,IManagedEc2EksComputeEnvironment,ManagedEc2EksComputeEnvironmentProps)
Would you be interested in contributing this fix?
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.