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

Allow to configure --scale-down-unneeded-time #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions pkg/apis/autoscaling/v1alpha1/clusterautoscaler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ type ScaleDownConfig struct {
DelayAfterAdd string `json:"delayAfterAdd"`
DelayAfterDelete string `json:"delayAfterDelete"`
DelayAfterFailure string `json:"delayAfterFailure"`
UnneededTime string `json:"unneededTime,omitempty"`
}
5 changes: 5 additions & 0 deletions pkg/controller/clusterautoscaler/clusterautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
ScaleDownDelayAfterAddArg AutoscalerArg = "--scale-down-delay-after-add"
ScaleDownDelayAfterDeleteArg AutoscalerArg = "--scale-down-delay-after-delete"
ScaleDownDelayAfterFailureArg AutoscalerArg = "--scale-down-delay-after-failure"
ScaleDownUnneededTimeArg AutoscalerArg = "--scale-down-unneeded-time"
MaxNodesTotalArg AutoscalerArg = "--max-nodes-total"
CoresTotalArg AutoscalerArg = "--cores-total"
MemoryTotalArg AutoscalerArg = "--memory-total"
Expand Down Expand Up @@ -96,6 +97,10 @@ func ScaleDownArgs(sd *v1alpha1.ScaleDownConfig) []string {
ScaleDownDelayAfterFailureArg.Value(sd.DelayAfterFailure),
}

if sd.UnneededTime != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a unit test case that validates a config with/without this value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should actually probably add omitEmpty to all of the scale down argument fields in the resource, or even make them pointers. Then fix the Value() method here to return an empty string if it gets nil or an empty string. Not sure if we do that here or in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote in a follow-up.

args = append(args, ScaleDownUnneededTimeArg.Value(sd.UnneededTime))
}

return args
}

Expand Down