mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
test: use correct pool allocation for spot strategy (#20593)
Determine the allocation pool size for the spot fleet by the allocation strategy. This allows us to ensure a consistent attribute plan during re-runs which avoid rebuilding the target fleets. Signed-off-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
@@ -161,6 +161,7 @@ resource "random_string" "unique_id" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
|
allocation_strategy = "lowestPrice"
|
||||||
instances = toset([for idx in range(var.instance_count) : tostring(idx)])
|
instances = toset([for idx in range(var.instance_count) : tostring(idx)])
|
||||||
cluster_name = coalesce(var.cluster_name, random_string.cluster_name.result)
|
cluster_name = coalesce(var.cluster_name, random_string.cluster_name.result)
|
||||||
name_prefix = "${var.project_name}-${local.cluster_name}-${random_string.unique_id.result}"
|
name_prefix = "${var.project_name}-${local.cluster_name}-${random_string.unique_id.result}"
|
||||||
@@ -314,11 +315,14 @@ resource "aws_launch_template" "target" {
|
|||||||
# Unless we see capacity issues or instances being shut down then we ought to
|
# Unless we see capacity issues or instances being shut down then we ought to
|
||||||
# stick with that strategy.
|
# stick with that strategy.
|
||||||
resource "aws_spot_fleet_request" "targets" {
|
resource "aws_spot_fleet_request" "targets" {
|
||||||
allocation_strategy = "lowestPrice"
|
allocation_strategy = local.allocation_strategy
|
||||||
fleet_type = "request"
|
fleet_type = "request"
|
||||||
iam_fleet_role = aws_iam_role.fleet.arn
|
iam_fleet_role = aws_iam_role.fleet.arn
|
||||||
// Set this to zero so re-runs don't plan for replacement
|
// The instance_pools_to_use_count is only valid for the allocation_strategy
|
||||||
instance_pools_to_use_count = 0
|
// lowestPrice. When we are using that strategy we'll want to always set it
|
||||||
|
// to 1 to avoid rebuilding the fleet on a re-run. For any other strategy
|
||||||
|
// set it to zero to avoid rebuilding the fleet on a re-run.
|
||||||
|
instance_pools_to_use_count = local.allocation_strategy == "lowestPrice" ? 1 : 0
|
||||||
target_capacity = var.instance_count
|
target_capacity = var.instance_count
|
||||||
terminate_instances_on_delete = true
|
terminate_instances_on_delete = true
|
||||||
wait_for_fulfillment = true
|
wait_for_fulfillment = true
|
||||||
|
|||||||
Reference in New Issue
Block a user