Skip to content

feat: add evictAfterOOMThreshold per vpa#9071

Open
omerap12 wants to merge 1 commit intokubernetes:masterfrom
omerap12:evictAfterOOMThreshold
Open

feat: add evictAfterOOMThreshold per vpa#9071
omerap12 wants to merge 1 commit intokubernetes:masterfrom
omerap12:evictAfterOOMThreshold

Conversation

@omerap12
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

evictAfterOOMThreshold is now per vpa 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

[AEP]: https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/8026-per-vpa-component-configuration

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jan 18, 2026
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-area labels Jan 18, 2026
@omerap12
Copy link
Member Author

/hold
/kind api-change
/label api-review

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. api-review Categorizes an issue or PR as actively needing an API review. labels Jan 18, 2026
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 25, 2026
@soltysh soltysh moved this to Backlog in API Reviews Jan 29, 2026
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Initial comments from API shadow

// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Format=duration
// +kubebuilder:validation:Pattern=`^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$`
EvictAfterOOMThreshold *metav1.Duration `json:"evictAfterOOMThreshold,omitempty" protobuf:"bytes,4,opt,name=evictAfterOOMThreshold"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have any metav1.Duration in the k/k APIs, and from a quick grep it seems we don't have them in this repo. So I'd suggest to stick with the usual units as described here https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#units. Example EvictAfterOOMSeconds or something like that.

Copy link
Member

Choose a reason for hiding this comment

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

I've added noduration to kube-api-linter: #9147

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if this matters, but, this field is an override to the --evict-after-oom-threshold flag, which is currently a duration:

evictAfterOOMThreshold = flag.Duration("evict-after-oom-threshold", 10*time.Minute,
`Evict pod that has OOMed in less than evict-after-oom-threshold since start.`)
)

Keeping the flag and API constant feels like a nice thing to do, but I'm assuming the reason listed in the api-conventions doc is higher priority:

We don't use Duration in the API since that would require clients to implement go-compatible parsing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Maciej (again) :)
@adrianmoisey , so let's go with EvictAfterOOMSeconds? I will update the AEP and this PR if that's ok with you.

Copy link
Contributor

@soltysh soltysh Feb 12, 2026

Choose a reason for hiding this comment

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

Keeping the flag and API constant feels like a nice thing to do, but I'm assuming the reason listed in the api-conventions doc is higher priority

Flags have better parsing capabilities and it's exposed only to cluster admins. API is user-facing and this would force clients to support go-compatible parsing rules, it's mentioned in our API conventions.

@liggitt liggitt moved this from Backlog to Changes requested in API Reviews Jan 29, 2026
@omerap12 omerap12 force-pushed the evictAfterOOMThreshold branch from 1ddfd7b to cb9dc87 Compare February 4, 2026 11:52

const (
// DefaultEvictAfterOOMThreshold is the default time threshold for evicting pods after OOM
DefaultEvictAfterOOMThreshold = 10 * time.Minute
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be public?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, any reason why this moved to a const? Seems like only 1 thing uses it

@omerap12 omerap12 force-pushed the evictAfterOOMThreshold branch from eb2d515 to e26f744 Compare February 8, 2026 10:02
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

One minor nit, but this lgtm from api-shadow pov

}

// PodUpdatePolicy describes the rules on how changes are applied to the pods.
// +kubebuilder:validation:XValidation:rule="!has(self.evictAfterOOMSeconds) || self.evictAfterOOMSeconds > 0",message="evictAfterOOMSeconds must be greater than 0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don't think you need double validation for > 0. You already have kubebuilder:validation:Minimum=1 set directly on the field.

Copy link
Member

Choose a reason for hiding this comment

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

agreed, let's not add CEL validation that redoes validation we already applied

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. thanks folks :)

@omerap12 omerap12 force-pushed the evictAfterOOMThreshold branch 3 times, most recently from c6fff23 to e034392 Compare February 13, 2026 13:38
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
@omerap12 omerap12 force-pushed the evictAfterOOMThreshold branch from e034392 to 81fe9f7 Compare February 13, 2026 13:40
@adrianmoisey
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianmoisey, omerap12, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

5 participants