Skip to content

Commit a6d986f

Browse files
committed
feat: support granular aggressive mode config in scheduled rebalancing
1 parent 1fe0630 commit a6d986f

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

castai/data_source_resource_rebalancing_schedule_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ func TestRebalancingScheduleDataSourceRead(t *testing.T) {
5050
"evictGracefully": false,
5151
"aggressiveMode": false,
5252
"aggressiveModeConfig": {
53-
"ignoreLocalPersistentVolumes": true
53+
"ignoreLocalPersistentVolumes": true,
54+
"ignoreProblemJobPods": true,
55+
"ignoreProblemRemovalDisabledPods": true,
56+
"ignoreProblemPodsWithoutController": true
5457
}
5558
},
5659
"numTargetedNodes": 20,
@@ -131,6 +134,9 @@ launch_configuration.# = 1
131134
launch_configuration.0.aggressive_mode = false
132135
launch_configuration.0.aggressive_mode_config.# = 1
133136
launch_configuration.0.aggressive_mode_config.0.ignore_local_persistent_volumes = true
137+
launch_configuration.0.aggressive_mode_config.0.ignore_problem_job_pods = true
138+
launch_configuration.0.aggressive_mode_config.0.ignore_problem_pods_without_controller = true
139+
launch_configuration.0.aggressive_mode_config.0.ignore_problem_removal_disabled_pods = true
134140
launch_configuration.0.execution_conditions.# = 1
135141
launch_configuration.0.execution_conditions.0.achieved_savings_percentage = 15
136142
launch_configuration.0.execution_conditions.0.enabled = true

castai/resource_rebalancing_schedule.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,22 @@ func resourceRebalancingSchedule() *schema.Resource {
131131
"ignore_local_persistent_volumes": {
132132
Type: schema.TypeBool,
133133
Required: true,
134-
Description: "Rebalance workloads using local-path Persistent Volumes. THIS WILL RESULT IN DATA LOSS.",
134+
Description: "Rebalance workloads that use local-path Persistent Volumes. THIS WILL RESULT IN DATA LOSS.",
135+
},
136+
"ignore_problem_job_pods": {
137+
Type: schema.TypeBool,
138+
Required: true,
139+
Description: "Pods spawned by Jobs or CronJobs will not prevent the Rebalancer from deleting a node on which they run. WARNING: When true, pods spawned by Jobs or CronJobs will be terminated if the Rebalancer picks a node that runs them. As such, they are likely to lose their progress.",
140+
},
141+
"ignore_problem_removal_disabled_pods": {
142+
Type: schema.TypeBool,
143+
Required: true,
144+
Description: `Pods that are marked with "removal disabled" will not prevent the Rebalancer from deleting a node on which they run. WARNING: When true, such pods will be evicted and disrupted.`,
145+
},
146+
"ignore_problem_pods_without_controller": {
147+
Type: schema.TypeBool,
148+
Required: true,
149+
Description: "Pods that don't have a controller (bare pods) will not prevent the Rebalancer from deleting a node on which they run. WARNING: When true, such pods might not restart, since they have no controller to do it.",
135150
},
136151
},
137152
},
@@ -314,7 +329,10 @@ func stateToSchedule(d *schema.ResourceData) (*sdk.ScheduledrebalancingV1Rebalan
314329
aggressiveModeConfigSection := launchConfigurationData["aggressive_mode_config"].([]any)
315330
if len(aggressiveModeConfigSection) != 0 {
316331
aggressiveModeConfig = &sdk.ScheduledrebalancingV1AggressiveModeConfig{
317-
IgnoreLocalPersistentVolumes: lo.ToPtr(aggressiveModeConfigSection[0].(map[string]any)["ignore_local_persistent_volumes"].(bool)),
332+
IgnoreLocalPersistentVolumes: lo.ToPtr(aggressiveModeConfigSection[0].(map[string]any)["ignore_local_persistent_volumes"].(bool)),
333+
IgnoreProblemJobPods: lo.ToPtr(aggressiveModeConfigSection[0].(map[string]any)["ignore_problem_job_pods"].(bool)),
334+
IgnoreProblemRemovalDisabledPods: lo.ToPtr(aggressiveModeConfigSection[0].(map[string]any)["ignore_problem_removal_disabled_pods"].(bool)),
335+
IgnoreProblemPodsWithoutController: lo.ToPtr(aggressiveModeConfigSection[0].(map[string]any)["ignore_problem_pods_without_controller"].(bool)),
318336
}
319337
}
320338

@@ -363,7 +381,10 @@ func scheduleToState(schedule *sdk.ScheduledrebalancingV1RebalancingSchedule, d
363381
if schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig != nil {
364382
launchConfig["aggressive_mode_config"] = []map[string]any{
365383
{
366-
"ignore_local_persistent_volumes": schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig.IgnoreLocalPersistentVolumes,
384+
"ignore_local_persistent_volumes": schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig.IgnoreLocalPersistentVolumes,
385+
"ignore_problem_job_pods": schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig.IgnoreProblemJobPods,
386+
"ignore_problem_removal_disabled_pods": schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig.IgnoreProblemRemovalDisabledPods,
387+
"ignore_problem_pods_without_controller": schedule.LaunchConfiguration.RebalancingOptions.AggressiveModeConfig.IgnoreProblemPodsWithoutController,
367388
},
368389
}
369390
}

examples/gke/gke_cluster_autoscaler_policies/castai.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module "castai-gke-iam" {
2626
}
2727

2828
module "castai-gke-cluster" {
29-
source = "castai/gke-cluster/castai"
29+
source = "../../../../terraform-castai-gke-cluster"
3030

3131
api_url = var.castai_api_url
3232
castai_api_token = var.castai_api_token

0 commit comments

Comments
 (0)