Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Allow 0 as rebalancing_min_nodes value #220

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading