Skip to content

Commit

Permalink
FIX: Allow 0 as rebalancing_min_nodes value
Browse files Browse the repository at this point in the history
  • Loading branch information
tautvydasliekis committed Aug 28, 2023
1 parent edd7ea6 commit f9ddc50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion castai/resource_rebalancing_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func resourceRebalancingSchedule() *schema.Resource {
"rebalancing_min_nodes": {
Type: schema.TypeInt,
Optional: true,
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(1)),
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(0)),
Description: "Minimum number of nodes that should be kept in the cluster after rebalancing.",
},
"keep_drain_timeout_nodes": {
Expand Down
29 changes: 29 additions & 0 deletions castai/resource_rebalancing_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ func TestAccResourceRebalancingSchedule_basic(t *testing.T) {
resource.TestCheckResourceAttr("castai_rebalancing_schedule.test", "schedule.0.cron", "1 4 * * *"),
),
},
{
Config: makeUpdatedMinNodes(rName + " min_nodes_zero"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("castai_rebalancing_schedule.test", "name", rName+" min_nodes_zero"),
resource.TestCheckResourceAttr("castai_rebalancing_schedule.test", "launch_configuration.0.rebalancing_min_nodes", "0"),
),
},
},
})
}
Expand Down Expand Up @@ -103,3 +110,25 @@ resource "castai_rebalancing_schedule" "test" {
`
return fmt.Sprintf(template, rName)
}

func makeUpdatedMinNodes(rName string) string {
template := `
resource "castai_rebalancing_schedule" "test" {
name = %q
schedule {
cron = "1 4 * * *"
}
trigger_conditions {
savings_percentage = 1.23456
}
launch_configuration {
rebalancing_min_nodes = 0
execution_conditions {
enabled = true
achieved_savings_percentage = 10
}
}
}
`
return fmt.Sprintf(template, rName)
}

0 comments on commit f9ddc50

Please sign in to comment.