Skip to content

Allow Customizing Spot Allocation Strategy #427

Open
@djmetzle

Description

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

EC2 allows choosing multiple allocation strategies for spot requests. It would be great to be able to specify the Allocation strategy for packer builds on Spot.

Use Case(s)

In our use case (building AMIs in CI/CD) we are seeing frequent evictions of spot instances mid-build, or even before launching the build instances. It could help to choose a strategy like capacity-optimized or price-capacity-optimized, in order to see less frequent evictions and failures due to lack of capacity.

Potential configuration

An option that exposes spot_allocation_strategy on the AWS builder would do the trick. That option could still default to lowest-price for backwards behavioral compatibility. But price-capacity-optimized is the recommended value.

Potential References

It looks like the AWS SDK exposes this configuration point as an Enum (sorry, this file is to big to permalink to):
https://github.com/aws/aws-sdk-go/blob/main/service/ec2/api.go

I think it would only be a matter of adding that option to the spot fleet request here?

createFleetInput := &ec2.CreateFleetInput{
LaunchTemplateConfigs: []*ec2.FleetLaunchTemplateConfigRequest{
{
LaunchTemplateSpecification: &ec2.FleetLaunchTemplateSpecificationRequest{
LaunchTemplateName: aws.String(launchTemplateName),
Version: aws.String("1"),
},
Overrides: overrides,
},
},
ReplaceUnhealthyInstances: aws.Bool(false),
TargetCapacitySpecification: &ec2.TargetCapacitySpecificationRequest{
TotalTargetCapacity: aws.Int64(1),
DefaultTargetCapacityType: aws.String("spot"),
},
Type: aws.String("instant"),
}

From there, a configuration option would need to be exposed from input and threaded to the fleet request.


Apologies if this is too vague, as i'm not very well versed in Go.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions