Skip to content

fix: expose on_demand_allocation_strategy to unblock instance_requirements#1381

Open
dmitrijn wants to merge 3 commits into
cattle-ops:mainfrom
dmitrijn:main
Open

fix: expose on_demand_allocation_strategy to unblock instance_requirements#1381
dmitrijn wants to merge 3 commits into
cattle-ops:mainfrom
dmitrijn:main

Conversation

@dmitrijn

@dmitrijn dmitrijn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

instance_requirements (attribute-based instance selection) was already supported
by this module, but applying it would fail at the AWS API level with:

ValidationError: The specified OnDemandAllocationStrategy is not valid.
The prioritized allocation strategy is not compatible with instance requirements.
Valid options are [lowest-price].

This happened because on_demand_allocation_strategy was not exposed by the module,
so AWS defaulted to prioritized, which it rejects when instance_requirements is used.

Changes

  • Add on_demand_allocation_strategy to runner_worker_docker_autoscaler_asg and
    pass it through to the ASG instances_distribution block
  • Default to lowest-price, consistent with the existing spot_allocation_strategy default
  • Add a validation that enforces lowest-price when instance_requirements is set,
    surfacing a clear terraform validate error instead of a misleading AWS 400 at apply time

Usage

To use attribute-based instance selection:

runner_worker_docker_autoscaler_asg = {
  enable_mixed_instances_policy = true
  on_demand_allocation_strategy = "lowest-price"
  instance_requirements = [{
    vcpu_count            = { min = 4, max = 16 }
    memory_mib            = { min = 16384, max = null }
    cpu_manufacturers     = ["amazon-web-services"]
    instance_generations  = ["current"]
    burstable_performance = "excluded"
  }]
}

@dmitrijn
dmitrijn requested review from kayman-mk and npalm as code owners June 25, 2026 15:51
@github-actions

Copy link
Copy Markdown
Contributor

Hey @dmitrijn! 👋

Thank you for your contribution to the project. Please refer to the contribution rules for a quick overview of the process.

Make sure that this PR clearly explains:

  • the problem being solved
  • the best way a reviewer and you can test your changes

With submitting this PR you confirm that you hold the rights of the code added and agree that it will published under this LICENSE.

The following ChatOps commands are supported:

  • /help: notifies a maintainer to help you out

Simply add a comment with the command in the first line. If you need to pass more information, separate it with a blank line from the command.

This message was generated automatically. You are welcome to improve it.

@dmitrijn

Copy link
Copy Markdown
Contributor Author

@npalm and @kayman-mk, could you please review this?

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.

1 participant